/* Hello, World! program example in C CSE 374, Winter 2015 */ /* Start with any necessary include statements to bring in definitions from libraries or any user-defined functions. */ #include /* main is a reserved keyword. The main function is where execution starts. The signature is similar to other functions: returnType functionName ( paramList ) { functionBody } where paramList can be empty or dataType varName pairs and pairs are separated by commas. In main, you have argc, the number (or count) of arguments, and argv, the values of the arguments. argv is a pointer to an array of pointers to the argument values. */ int main(int argc, char** argv) { /* The body of the function is contained within a matched pair of { } C does not care whether the { is on the same line with the function signature or not, and white space is up to the developer or any imposed stylistic standards (like Java). */ /* a basic printf statement with one string as an argument to the function printf. \n is a newline character. */ printf("Hello, World\n"); /* The following is a return statement. return in main() is similar to an exit command in a shell script. The value will be returned to the operating system when the program is done. Usually a zero value means everything was fine, and other numbers can be used at the developer's discretion to signal various problems during execution. */ return 0; }