Structures, Unions - Introduction to Programming - Lecture Slides, Slides of Computer Programming

Structures, Unions, Structure definition, Variables of type structure, Pointers to Structure, Array of Structure, Initializing Structures, Accessing structure members are the key points of this lecture.

Typology: Slides

2011/2012

Uploaded on 11/06/2012

somo
somo 🇮🇳

4.8

(4)

70 documents

1 / 49

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Programming
Lecture 20
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31

Partial preview of the text

Download Structures, Unions - Introduction to Programming - Lecture Slides and more Slides Computer Programming in PDF only on Docsity!

Introduction to Programming

Lecture 20

In the Last Two Lectures

 File Handling

  • Sequential Files
  • Random Access Files

Structure

Structure definition struct Student { char name [ 60 ] ; char address [ 100 ] ; Data of the structure double gpa ; } ; Structure name

Keyword

Structure struct address { char streetAddress [ 100 ] ; char city [ 30 ] ; char country [ 30 ] ; }

Structure struct Student { char name [ 60 ] ; address add ; double gpa ; } s1 , s2 , s3 ;

Structures

Variables of type structure

Pointers to Structure

Array of Structure

Student s [ 100 ] ; Student *sPtr ; Structures

Student s1 , s2 ; s1 = s2 ; Structures

Example 2 struct Student { char name [ 64 ] ; char course [ 128 ] ; int age ; int year ; } ;

Initializing Structures

s1.name ;

s1.course ;

s1.age ;

s1.year ;

Initializing Structures

s1.age = 20 ; s1.name = “Abbas Ali ” ; //Wrong strcpy ( s1.name , “Abbas Ali ” ) ;

Assignment of structures Student s1 , s2 ; s2 = s1 ;

Passing Structures to Functions