SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
Structure
2
Declaring Structures
§ Array와 structure의 차이점
– array
• Array의 모든 element는 같은 type이여야 한다.
• Index를 사용하여 각 element를 access한다.
– structure
• 다른 type의 element로 구성 될 수 있다.
• 각 element는 name을 갖는다.
• Name에 의해 각 element를 access한다.
3
Declaring Structures
§ struct declaration
– Collection of members(/elements)
[Ex] struct student { /* 2 elements로 구성된 structure */
int std_id;
char name [20] ;
} ;
int std_id, char name[20]
2 member를 포함하는 student라 불리우는 struct type을 정의
4
Declaring Structures
§ struct declaration
- struct tag: 정의 되는 structure를 지정하기 위한 name.
- 한 번 structure tag인 student가 정의되면, 이제 tag를 사용하
여 같은 structure type의 변수를 선언할 수 있다.
[Ex] struct student {
int std_id;
char name [20] ;
};
[Ex] struct student p1, p2 ; /* correct declaration */
student p1, p2; /* wrong declaration */
struct tag:
생략 가능하지만..
5
Accessing a Member
§ struct member operator ‘.’
– Structure의 각 member를 access하기 위해 ‘.’를 사용한다.
[Ex] struct student {
int std_id;
char name[20];
} ;
struct student p ;
p.std_id = 1 ;
strcpy( p.name, “Monica” ) ;
1
Monica
p
std_id
name
6
Accessing a Member
§ member operation
[Ex] struct student {
int std_id;
char name[20];
}
struct student p ;
scanf(“%s”, p.name);
p.std_id = 258; /* assignment */
p.std_id++; /* increment */
7
Declaring Structures
§ Example
int main()
{
int std_id ;
char name[20] ;
scanf( “%d”, &std_id ) ;
scanf( “%s”, name ) ;
printf( “%d ”, std_id ) ;
scanf( “%sn”, name ) ;
return 0;
}
struct student {
int std_id;
char name [20] ;
} ;
int main()
{
struct student p ;
scanf( “%d”, &p.std_id ) ;
scanf( “%s”, p.name ) ;
printf( “%d ”, p.std_id ) ;
printf( “%sn”, p.name ) ;
return 0;
}
8
Declaring Structures
§ Initializing Struct variables
[Ex] struct student {
int std_id;
char name [20] ;
} ;
struct student person1 = { 1, “Gil Dong” } ;
struct student person2 = { 2, “Sun Shin” } ;
person1
person1.number person1.name
1 Gil Dong person2
person2.number person2.name
2 Sun Shin
9
Structure Pointer
§ Pointer 선언
[Ex] struct student {
int std_id;
char name[20];
} ;
struct student s={1, “Gil Dong”}, *p ;
p = &s ;
s
1 Gil Dong
p
10
Structure Pointer
§ Pointer를 통한 member access
[Ex] struct student {
int std_id;
char name[20];
} ;
struct student s, *p = &s ;
(*p).std_id = 10 ;
strcpy( (*p).name, “Sun Shin” ) ;
struct student s, *p = &s ;
p->std_id = 10 ;
strcpy( p->name, “Sun Shin” ) ;
11
Structure Pointer
[Ex] struct shape {
int x, y ;
char name[10] ;
};
struct shape s, *p = &s;
scanf (“%d %d %s”, &p->x , &p->y, p->name ) ;
p->x *= 2;
p->y %= 5;
printf (“%d %d %sn”, p->x , p->y, p->name ) ;
12
Structure Pointer
[Ex] struct shape {
int x, y ;
char name[10] ;
};
struct shape s, *p = &s;
scanf (“%d %d %s”, &(*p).x , &(*p).y, (*p).name ) ;
(*p).x *= 2;
(*p).y %= 5;
printf (“%d %d %sn”, (*p).x , (*p). y, (*p). name ) ;
13
Precedence and Associativity of Operators
( ) [ ] . -> ++(postfix) --(postfix) left to right
++(prefix) --(prefix) ! ~ sizeof(type)
+(unary) -(unary) &(address) *(dereference)
right to left
* / % left to right
+ - left to right
<< >> left to right
< <= > >= left to right
== != left to right
& left to right
^ left to right
| left to right
&& left to right
|| left to right
? : right to left
= += -= *= /= %= >>= <<= &= ^= |= right to left
14
Functions and Assignment
§ struct 변수에 값 넣기
struct student {
int std_id;
char name[20];
} p1, p2;
struct student p1 = { 1, “Gil Dong”}, p2 ;
p2 = p1 ; // OK???
1
Gil Dong
p1
?
?
p2
OK. 원하는 대로 잘 됨
15
Functions and Assignment
§ struct 변수에 값 넣기
struct student {
int std_id;
char name[20];
} ;
int main() {
struct student p1 = { 1, “Gil Dong”}, p2 ;
copy_student( p1, p2 ) ;
return 0;
}
void copy_student( struct student p1,
struct student p2 )
{
p1.std_id = p2.std_id ;
strcpy( p1.name, p2.name ) ;
}
p2의 값은 어떻게 될까?
16
Functions and Assignment
§ struct 변수에 값 넣기
void copy_student( struct student *p1,
struct student *p2 )
{
p1->std_id = p2->std_id ;
strcpy( p1->name, p2->name ) ;
}
struct student {
int std_id;
char name[20];
} ;
int main() {
struct student p1 = { 1, “Gil Dong”}, p2 ;
copy_student( &p1, &p2 ) ;
return 0;
}
p2의 값은 어떻게 될까?
17
Arrays of Structure
§ Definition
[Ex] struct student {
int std_id;
char name[20];
} ;
struct student my_student[100] ;
my_student[0]
1 Gil Dong
my_student[1]
5 Sun Shin ………
18
Initialization of Structures
§ Initializing an Array of Structures
[Ex] struct student {
int std_id ;
char name[20] ;
} ;
struct student my_student[20] =
{ {1, “Gil Dong”},
{2, “Sun Sin”},
{3, “Kuk Jung”},
:
} ;

Mais conteúdo relacionado

Mais procurados

Mais procurados (14)

5. hello popescu
5. hello popescu5. hello popescu
5. hello popescu
 
11. delete record
11. delete record11. delete record
11. delete record
 
10. view one record
10. view one record10. view one record
10. view one record
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
 
Object::Franger: Wear a Raincoat in your Code
Object::Franger: Wear a Raincoat in your CodeObject::Franger: Wear a Raincoat in your Code
Object::Franger: Wear a Raincoat in your Code
 
Command-Oriented Architecture
Command-Oriented ArchitectureCommand-Oriented Architecture
Command-Oriented Architecture
 
Smarty
SmartySmarty
Smarty
 
Writing testable js [by Ted Piotrowski]
Writing testable js [by Ted Piotrowski]Writing testable js [by Ted Piotrowski]
Writing testable js [by Ted Piotrowski]
 
Validation using javascripts by karan chanana
Validation using javascripts by karan chananaValidation using javascripts by karan chanana
Validation using javascripts by karan chanana
 
Advanced theming
Advanced themingAdvanced theming
Advanced theming
 
Bacbkone js
Bacbkone jsBacbkone js
Bacbkone js
 
Jquery plugin development
Jquery plugin developmentJquery plugin development
Jquery plugin development
 
Crash Course to SQL in PHP
Crash Course to SQL in PHPCrash Course to SQL in PHP
Crash Course to SQL in PHP
 
14. CodeIgniter adaugarea inregistrarilor
14. CodeIgniter adaugarea inregistrarilor14. CodeIgniter adaugarea inregistrarilor
14. CodeIgniter adaugarea inregistrarilor
 

Destaque

5 2. string processing
5 2. string processing5 2. string processing
5 2. string processing웅식 전
 
5 2. string processing
5 2. string processing5 2. string processing
5 2. string processing웅식 전
 
Pattern matching
Pattern matchingPattern matching
Pattern matchingshravs_188
 

Destaque (6)

5 2. string processing
5 2. string processing5 2. string processing
5 2. string processing
 
5 2. string processing
5 2. string processing5 2. string processing
5 2. string processing
 
String matching algorithms
String matching algorithmsString matching algorithms
String matching algorithms
 
String matching algorithm
String matching algorithmString matching algorithm
String matching algorithm
 
Pattern matching
Pattern matchingPattern matching
Pattern matching
 
String matching algorithms
String matching algorithmsString matching algorithms
String matching algorithms
 

Semelhante a 13. structure

12 2. structure
12 2. structure12 2. structure
12 2. structure웅식 전
 
FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2rohassanie
 
Structures in C.pptx
Structures in C.pptxStructures in C.pptx
Structures in C.pptxBoni Yeamin
 
CHAPTER -4-class and structure.pptx
CHAPTER -4-class and structure.pptxCHAPTER -4-class and structure.pptx
CHAPTER -4-class and structure.pptxGebruGetachew2
 
VIT351 Software Development VI Unit4
VIT351 Software Development VI Unit4VIT351 Software Development VI Unit4
VIT351 Software Development VI Unit4YOGESH SINGH
 
Presentation on structure,functions and classes
Presentation on structure,functions and classesPresentation on structure,functions and classes
Presentation on structure,functions and classesAlisha Korpal
 
STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING Gurwinderkaur45
 
Pointers and Structures
Pointers and StructuresPointers and Structures
Pointers and StructuresGem WeBlog
 
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...Smit Shah
 
358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7sumitbardhan
 
data structure and c programing concepts
data structure and c programing conceptsdata structure and c programing concepts
data structure and c programing conceptskavitham66441
 

Semelhante a 13. structure (20)

12 2. structure
12 2. structure12 2. structure
12 2. structure
 
FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2
 
Structures in C.pptx
Structures in C.pptxStructures in C.pptx
Structures in C.pptx
 
Structures
StructuresStructures
Structures
 
Unit4 C
Unit4 C Unit4 C
Unit4 C
 
CHAPTER -4-class and structure.pptx
CHAPTER -4-class and structure.pptxCHAPTER -4-class and structure.pptx
CHAPTER -4-class and structure.pptx
 
Structure & union
Structure & unionStructure & union
Structure & union
 
Structures and Unions
Structures and UnionsStructures and Unions
Structures and Unions
 
VIT351 Software Development VI Unit4
VIT351 Software Development VI Unit4VIT351 Software Development VI Unit4
VIT351 Software Development VI Unit4
 
Presentation on structure,functions and classes
Presentation on structure,functions and classesPresentation on structure,functions and classes
Presentation on structure,functions and classes
 
STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING
 
Pointers and Structures
Pointers and StructuresPointers and Structures
Pointers and Structures
 
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
 
Ch7 structures
Ch7 structuresCh7 structures
Ch7 structures
 
358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7
 
Unit 5 (1)
Unit 5 (1)Unit 5 (1)
Unit 5 (1)
 
Structures
StructuresStructures
Structures
 
Structures in c
Structures in cStructures in c
Structures in c
 
data structure and c programing concepts
data structure and c programing conceptsdata structure and c programing concepts
data structure and c programing concepts
 
User defined data types.pptx
User defined data types.pptxUser defined data types.pptx
User defined data types.pptx
 

Mais de 웅식 전

15 3. modulization
15 3. modulization15 3. modulization
15 3. modulization웅식 전
 
15 2. arguement passing to main
15 2. arguement passing to main15 2. arguement passing to main
15 2. arguement passing to main웅식 전
 
12 2. dynamic allocation
12 2. dynamic allocation12 2. dynamic allocation
12 2. dynamic allocation웅식 전
 
12 1. multi-dimensional array
12 1. multi-dimensional array12 1. multi-dimensional array
12 1. multi-dimensional array웅식 전
 
11. array & pointer
11. array & pointer11. array & pointer
11. array & pointer웅식 전
 
10. pointer & function
10. pointer & function10. pointer & function
10. pointer & function웅식 전
 
7. variable scope rule,-storage_class
7. variable scope rule,-storage_class7. variable scope rule,-storage_class
7. variable scope rule,-storage_class웅식 전
 
5 1. character processing
5 1. character processing5 1. character processing
5 1. character processing웅식 전
 
15 1. enumeration, typedef
15 1. enumeration, typedef15 1. enumeration, typedef
15 1. enumeration, typedef웅식 전
 
3 2. if statement
3 2. if statement3 2. if statement
3 2. if statement웅식 전
 
3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib웅식 전
 
2 3. standard io
2 3. standard io2 3. standard io
2 3. standard io웅식 전
 
2 2. operators
2 2. operators2 2. operators
2 2. operators웅식 전
 
2 1. variables & data types
2 1. variables & data types2 1. variables & data types
2 1. variables & data types웅식 전
 
Goorm ide 교육용버전 for skku(학생)
Goorm ide 교육용버전 for skku(학생)Goorm ide 교육용버전 for skku(학생)
Goorm ide 교육용버전 for skku(학생)웅식 전
 
구름 기본 소개자료
구름 기본 소개자료구름 기본 소개자료
구름 기본 소개자료웅식 전
 

Mais de 웅식 전 (20)

15 3. modulization
15 3. modulization15 3. modulization
15 3. modulization
 
15 2. arguement passing to main
15 2. arguement passing to main15 2. arguement passing to main
15 2. arguement passing to main
 
14. fiile io
14. fiile io14. fiile io
14. fiile io
 
12 2. dynamic allocation
12 2. dynamic allocation12 2. dynamic allocation
12 2. dynamic allocation
 
12 1. multi-dimensional array
12 1. multi-dimensional array12 1. multi-dimensional array
12 1. multi-dimensional array
 
11. array & pointer
11. array & pointer11. array & pointer
11. array & pointer
 
10. pointer & function
10. pointer & function10. pointer & function
10. pointer & function
 
9. pointer
9. pointer9. pointer
9. pointer
 
7. variable scope rule,-storage_class
7. variable scope rule,-storage_class7. variable scope rule,-storage_class
7. variable scope rule,-storage_class
 
6. function
6. function6. function
6. function
 
5 1. character processing
5 1. character processing5 1. character processing
5 1. character processing
 
15 1. enumeration, typedef
15 1. enumeration, typedef15 1. enumeration, typedef
15 1. enumeration, typedef
 
4. loop
4. loop4. loop
4. loop
 
3 2. if statement
3 2. if statement3 2. if statement
3 2. if statement
 
3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib
 
2 3. standard io
2 3. standard io2 3. standard io
2 3. standard io
 
2 2. operators
2 2. operators2 2. operators
2 2. operators
 
2 1. variables & data types
2 1. variables & data types2 1. variables & data types
2 1. variables & data types
 
Goorm ide 교육용버전 for skku(학생)
Goorm ide 교육용버전 for skku(학생)Goorm ide 교육용버전 for skku(학생)
Goorm ide 교육용버전 for skku(학생)
 
구름 기본 소개자료
구름 기본 소개자료구름 기본 소개자료
구름 기본 소개자료
 

Último

29042024_First India Newspaper Jaipur.pdf
29042024_First India Newspaper Jaipur.pdf29042024_First India Newspaper Jaipur.pdf
29042024_First India Newspaper Jaipur.pdfFIRST INDIA
 
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docxkfjstone13
 
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Development
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's DevelopmentNara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Development
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Developmentnarsireddynannuri1
 
HARNESSING AI FOR ENHANCED MEDIA ANALYSIS A CASE STUDY ON CHATGPT AT DRONE EM...
HARNESSING AI FOR ENHANCED MEDIA ANALYSIS A CASE STUDY ON CHATGPT AT DRONE EM...HARNESSING AI FOR ENHANCED MEDIA ANALYSIS A CASE STUDY ON CHATGPT AT DRONE EM...
HARNESSING AI FOR ENHANCED MEDIA ANALYSIS A CASE STUDY ON CHATGPT AT DRONE EM...Ismail Fahmi
 
Pakistan PMLN Election Manifesto 2024.pdf
Pakistan PMLN Election Manifesto 2024.pdfPakistan PMLN Election Manifesto 2024.pdf
Pakistan PMLN Election Manifesto 2024.pdfFahimUddin61
 
26042024_First India Newspaper Jaipur.pdf
26042024_First India Newspaper Jaipur.pdf26042024_First India Newspaper Jaipur.pdf
26042024_First India Newspaper Jaipur.pdfFIRST INDIA
 
Israel Palestine Conflict, The issue and historical context!
Israel Palestine Conflict, The issue and historical context!Israel Palestine Conflict, The issue and historical context!
Israel Palestine Conflict, The issue and historical context!Krish109503
 
Nurturing Families, Empowering Lives: TDP's Vision for Family Welfare in Andh...
Nurturing Families, Empowering Lives: TDP's Vision for Family Welfare in Andh...Nurturing Families, Empowering Lives: TDP's Vision for Family Welfare in Andh...
Nurturing Families, Empowering Lives: TDP's Vision for Family Welfare in Andh...narsireddynannuri1
 
Vashi Escorts, {Pooja 09892124323}, Vashi Call Girls
Vashi Escorts, {Pooja 09892124323}, Vashi Call GirlsVashi Escorts, {Pooja 09892124323}, Vashi Call Girls
Vashi Escorts, {Pooja 09892124323}, Vashi Call GirlsPooja Nehwal
 
Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...
Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...
Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...AlexisTorres963861
 
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdf30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdfFIRST INDIA
 
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover Back
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover BackVerified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover Back
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover BackPsychicRuben LoveSpells
 
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptxLorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptxlorenzodemidio01
 
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...Diya Sharma
 
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s LeadershipTDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadershipanjanibaddipudi1
 
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...Axel Bruns
 
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptx
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptxKAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptx
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptxjohnandrewcarlos
 

Último (20)

29042024_First India Newspaper Jaipur.pdf
29042024_First India Newspaper Jaipur.pdf29042024_First India Newspaper Jaipur.pdf
29042024_First India Newspaper Jaipur.pdf
 
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx
 
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Development
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's DevelopmentNara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Development
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Development
 
HARNESSING AI FOR ENHANCED MEDIA ANALYSIS A CASE STUDY ON CHATGPT AT DRONE EM...
HARNESSING AI FOR ENHANCED MEDIA ANALYSIS A CASE STUDY ON CHATGPT AT DRONE EM...HARNESSING AI FOR ENHANCED MEDIA ANALYSIS A CASE STUDY ON CHATGPT AT DRONE EM...
HARNESSING AI FOR ENHANCED MEDIA ANALYSIS A CASE STUDY ON CHATGPT AT DRONE EM...
 
Pakistan PMLN Election Manifesto 2024.pdf
Pakistan PMLN Election Manifesto 2024.pdfPakistan PMLN Election Manifesto 2024.pdf
Pakistan PMLN Election Manifesto 2024.pdf
 
26042024_First India Newspaper Jaipur.pdf
26042024_First India Newspaper Jaipur.pdf26042024_First India Newspaper Jaipur.pdf
26042024_First India Newspaper Jaipur.pdf
 
Israel Palestine Conflict, The issue and historical context!
Israel Palestine Conflict, The issue and historical context!Israel Palestine Conflict, The issue and historical context!
Israel Palestine Conflict, The issue and historical context!
 
Nurturing Families, Empowering Lives: TDP's Vision for Family Welfare in Andh...
Nurturing Families, Empowering Lives: TDP's Vision for Family Welfare in Andh...Nurturing Families, Empowering Lives: TDP's Vision for Family Welfare in Andh...
Nurturing Families, Empowering Lives: TDP's Vision for Family Welfare in Andh...
 
Vashi Escorts, {Pooja 09892124323}, Vashi Call Girls
Vashi Escorts, {Pooja 09892124323}, Vashi Call GirlsVashi Escorts, {Pooja 09892124323}, Vashi Call Girls
Vashi Escorts, {Pooja 09892124323}, Vashi Call Girls
 
Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...
Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...
Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...
 
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
 
30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdf30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdf
 
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
 
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover Back
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover BackVerified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover Back
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover Back
 
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptxLorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
 
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...
 
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s LeadershipTDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
 
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
 
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort Service
 
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptx
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptxKAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptx
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptx
 

13. structure

  • 2. 2 Declaring Structures § Array와 structure의 차이점 – array • Array의 모든 element는 같은 type이여야 한다. • Index를 사용하여 각 element를 access한다. – structure • 다른 type의 element로 구성 될 수 있다. • 각 element는 name을 갖는다. • Name에 의해 각 element를 access한다.
  • 3. 3 Declaring Structures § struct declaration – Collection of members(/elements) [Ex] struct student { /* 2 elements로 구성된 structure */ int std_id; char name [20] ; } ; int std_id, char name[20] 2 member를 포함하는 student라 불리우는 struct type을 정의
  • 4. 4 Declaring Structures § struct declaration - struct tag: 정의 되는 structure를 지정하기 위한 name. - 한 번 structure tag인 student가 정의되면, 이제 tag를 사용하 여 같은 structure type의 변수를 선언할 수 있다. [Ex] struct student { int std_id; char name [20] ; }; [Ex] struct student p1, p2 ; /* correct declaration */ student p1, p2; /* wrong declaration */ struct tag: 생략 가능하지만..
  • 5. 5 Accessing a Member § struct member operator ‘.’ – Structure의 각 member를 access하기 위해 ‘.’를 사용한다. [Ex] struct student { int std_id; char name[20]; } ; struct student p ; p.std_id = 1 ; strcpy( p.name, “Monica” ) ; 1 Monica p std_id name
  • 6. 6 Accessing a Member § member operation [Ex] struct student { int std_id; char name[20]; } struct student p ; scanf(“%s”, p.name); p.std_id = 258; /* assignment */ p.std_id++; /* increment */
  • 7. 7 Declaring Structures § Example int main() { int std_id ; char name[20] ; scanf( “%d”, &std_id ) ; scanf( “%s”, name ) ; printf( “%d ”, std_id ) ; scanf( “%sn”, name ) ; return 0; } struct student { int std_id; char name [20] ; } ; int main() { struct student p ; scanf( “%d”, &p.std_id ) ; scanf( “%s”, p.name ) ; printf( “%d ”, p.std_id ) ; printf( “%sn”, p.name ) ; return 0; }
  • 8. 8 Declaring Structures § Initializing Struct variables [Ex] struct student { int std_id; char name [20] ; } ; struct student person1 = { 1, “Gil Dong” } ; struct student person2 = { 2, “Sun Shin” } ; person1 person1.number person1.name 1 Gil Dong person2 person2.number person2.name 2 Sun Shin
  • 9. 9 Structure Pointer § Pointer 선언 [Ex] struct student { int std_id; char name[20]; } ; struct student s={1, “Gil Dong”}, *p ; p = &s ; s 1 Gil Dong p
  • 10. 10 Structure Pointer § Pointer를 통한 member access [Ex] struct student { int std_id; char name[20]; } ; struct student s, *p = &s ; (*p).std_id = 10 ; strcpy( (*p).name, “Sun Shin” ) ; struct student s, *p = &s ; p->std_id = 10 ; strcpy( p->name, “Sun Shin” ) ;
  • 11. 11 Structure Pointer [Ex] struct shape { int x, y ; char name[10] ; }; struct shape s, *p = &s; scanf (“%d %d %s”, &p->x , &p->y, p->name ) ; p->x *= 2; p->y %= 5; printf (“%d %d %sn”, p->x , p->y, p->name ) ;
  • 12. 12 Structure Pointer [Ex] struct shape { int x, y ; char name[10] ; }; struct shape s, *p = &s; scanf (“%d %d %s”, &(*p).x , &(*p).y, (*p).name ) ; (*p).x *= 2; (*p).y %= 5; printf (“%d %d %sn”, (*p).x , (*p). y, (*p). name ) ;
  • 13. 13 Precedence and Associativity of Operators ( ) [ ] . -> ++(postfix) --(postfix) left to right ++(prefix) --(prefix) ! ~ sizeof(type) +(unary) -(unary) &(address) *(dereference) right to left * / % left to right + - left to right << >> left to right < <= > >= left to right == != left to right & left to right ^ left to right | left to right && left to right || left to right ? : right to left = += -= *= /= %= >>= <<= &= ^= |= right to left
  • 14. 14 Functions and Assignment § struct 변수에 값 넣기 struct student { int std_id; char name[20]; } p1, p2; struct student p1 = { 1, “Gil Dong”}, p2 ; p2 = p1 ; // OK??? 1 Gil Dong p1 ? ? p2 OK. 원하는 대로 잘 됨
  • 15. 15 Functions and Assignment § struct 변수에 값 넣기 struct student { int std_id; char name[20]; } ; int main() { struct student p1 = { 1, “Gil Dong”}, p2 ; copy_student( p1, p2 ) ; return 0; } void copy_student( struct student p1, struct student p2 ) { p1.std_id = p2.std_id ; strcpy( p1.name, p2.name ) ; } p2의 값은 어떻게 될까?
  • 16. 16 Functions and Assignment § struct 변수에 값 넣기 void copy_student( struct student *p1, struct student *p2 ) { p1->std_id = p2->std_id ; strcpy( p1->name, p2->name ) ; } struct student { int std_id; char name[20]; } ; int main() { struct student p1 = { 1, “Gil Dong”}, p2 ; copy_student( &p1, &p2 ) ; return 0; } p2의 값은 어떻게 될까?
  • 17. 17 Arrays of Structure § Definition [Ex] struct student { int std_id; char name[20]; } ; struct student my_student[100] ; my_student[0] 1 Gil Dong my_student[1] 5 Sun Shin ………
  • 18. 18 Initialization of Structures § Initializing an Array of Structures [Ex] struct student { int std_id ; char name[20] ; } ; struct student my_student[20] = { {1, “Gil Dong”}, {2, “Sun Sin”}, {3, “Kuk Jung”}, : } ;