Professional Documents
Culture Documents
struct Person
{
char name[50];
int age;
float salary;
};
Create structure variable
struct Person
struct Person
{
{
char name[50];
char name[50];
int age;
int age;
float salary;
float salary;
};
} person1, person2, p[20];
int main()
{
struct Person person1, person2, p[20];
return 0;
}
Keyword typedef
struct number
{
struct complex comp;
int integers;
} num1, num2;
Structures & Pointers
• Structures can be accessed using pointers. Here's how:
%[^\n] scans everything until a \n, but doesn't scan in the \n.
%*c scans a single character, which will be the \n left over by %*[^\n] in this case. The
asterisk instructs scanf to discard the scanned character.
• https://www.cs.princeton.edu/courses/archive/spring2000/cs126/exe
rcises/structs.txt