I have exams tomorrow morning, so i need a answer soon(if it is possible)...i know that we will have a program about structs and files. First, if anyone knows the most important points in structs please post me and second i have a question about a program...here is the code:
obviously the next program does not compile correct. I try to understand some differences about structs. More specific about passing printing parametres in structs. My teacher told us that we should think structs like boxes. This is what i do. So, i imagine something like the following and i want to correct me if i am wrong.
There is one big box (struct Foo) which contains:
1) a box named foo
2) a box named group1
3) a box named group2
and finally each one of these 3 boxes contains x and y variable.
CORRECT? WRONG?
Code:#include <stdio.h> #include <stdlib.h> struct Foo{ int x; int y; }group1,group2; int main(void){ struct Foo foo; printf("x: %d\n", struct Foo.x); printf("y: %d\n", struct Foo.y); printf("x: %d\n", foo.x); printf("y: %d\n", foo.y); printf("x: %d\n", group1.x); printf("y: %d\n", group1.y); return 0; }



LinkBack URL
About LinkBacks



