Lecture 3

0 structures struct person mystring name int age

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: write(S1, N) write N characters only. • getline(S, count) reads in count-1 characters, even if whitespace is contained. Then a ‘ is appended. \0’ Structures struct person { my_string Name; int Age; float GPA; }; 13 Initialization and Assignment • person jamie = {“Jamie Fay”, 19, 3.1}; • Structures may be copied by “=“. • Structures may be passed by value. • Structures may be returned from functions. • Structures may be nested. • Arrays of Structures may be built. 15 More Examples typedef person many_people [large_const]; // def many_people many_people cis114; //cis114 is an array of // large_constant people cis114[3].Age // a member of the 4th array // element 17 14 Structure Examples struct addr { int Number; my_string Street; }; struct person { addr address; // and more stuff of course }; 16 File Input/Output • If you know how to use fprintf...
View Full Document

This document was uploaded on 03/31/2014 for the course CS 114 at NJIT.

Ask a homework question - tutors are online