all. I actually have two questions, several related.
Question # 1: Why does gcc allow me to declare variables after action statements? I thought the C89 standard did not allow this. (GCC Version: 4.4.3) This happens even when I explicitly use --std=c89the compilation line. I know that most compilers implement things that are non-standard, i.e. C compilers allowing //comments when the standard does not indicate this. I would like to know only the standard, so if I ever need to use only the standard, I do not focus on such things.
Question # 2: How do you deal without objects in C? I program as a hobby, and I have not yet used a language that has no objects (aka OO?). I already know some C ++, and I would like to learn how to use C on my own. Presumably, one way is to create a POD structure and create functions similar StructName_constructor(), StructName_doSomething()etc., And pass an instance of the structure of each function - is this the "right" way, or am I completely disabled?
EDIT: Due to some slight confusion, I determine that my second question is clearer: I don't ask. How do I use Objects in C?I ask How do you manage without objects in C?, how do you do things without objects, where do you usually use objects?
Thanks in advance. I have never used a language without OOP! :)
EDIT: as requested, here is an example of a problem with a variable declaration:
int main(int argc, char *argv[]) {
int myInt = 5;
printf("myInt is %d\n", myInt);
int test = 4;
printf("Test is %d\n", test);
return 0;
}