CSC209H5 Chapter Notes - Chapter 4: C String Handling

10 views4 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) Similar to an array where you can store other types. Declaration details yes type and number of elements array [] notation. Access via index notation not required types of members struct keyword dot notation. #include int main( void ) { struct student { good_student. last_name); char first_name[ 20 ]; char last_name[ 20 ] int year; float gpa; struct student good_student; strcpy(good_student. first_name, "jo" ); strcpy(good_student. last_name, "smith" ); good_student. year = 2 ; good_student. gpa = 3. 2 ; printf( "name: %s %s\n" , good_student. first_name, printf( "year: %d. #include void change( int numbers[]) { numbers[ 0 ] = 80 ; int main( void ) { int my_array[ 5 ]; my_array[ 0 ] = 40 ; change(my_array); printf( "element at index 0: %d\n" , my_array[ 0 ]); return 0 ; An array passes the pointer to the function. When you pass structures, it only passes a copy not the original.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents