1) Declaring is the way a programmer tells the compiler to expect a particular t ype, be it a variable, class/struct/union type

, a function type (prototype) or a particular object instance. (ie. extern int i) Declaration never reserves any space for the variable or instance in the program 's memory; it simply a "hint" to the compiler that a use of the variable or inst ance is expected in the program. This hinting is technically called "forward ref erence". Declaring a variable means describing its type to the compiler but not allocatin g any space for it. Defining a variable means declaring it and also allocating s pace to hold the variable. You can also initialize a variable at the time it is defined. Here is a declaration of a variable and a structure, and two variable d efinitions, one with initialization: extern int decl1; /* this is a declaration */ struct decl2 { int member; }; /* this just declares the type--no variable mentioned */ int def1 = 8; /* this is a definition */ int def2; /* this is a definition */ To put it another way, a declaration says to the compiler, "Somewhere in my prog ram will be a variable with this name, and this is what type it is." A definitio n says, "Right here is this variable with this name and this type." A variable can be declared many times, but it must be defined exactly once. For this reason, definitions do not belong in header files, where they might get #in cluded into more than one place in your program.

2) One technique that can be helpful if you find yourself with a large number of function parameters is to put your function parameters in a structure 3) The exit() function is used to exit your program and return control to the op erating system. The return statement is used to return from a function and retur n control to the calling function

Sign up to vote on this title
UsefulNot useful