notes on C programming taken from: The C programming Language by Brian W. Kernigan and Dennis M. Ritchie see p 6,7 --------------------------------------------------------------------------- #include main () { printf ("hello, world\n"); } =========================================================================== #include include information about standard library. Tells the compiler to include information about the standard input/output library. --------------------------------------------------------------------------- main() define a function named main that receives no argument values. --------------------------------------------------------------------------- { statements of main are enclosed in braces. --------------------------------------------------------------------------- printf ("hello, world\n"); main calls library function printf to print this sequence of characters; \n represents the newline character. --------------------------------------------------------------------------- } The statement of a function are enclosed in braces {}. =========================================================================== () empty list --------------------------------------------------------------------------- printf ("hello, world \n"); A function is called by naming it, followed by a parenthesized list of arguments, so this calls the function printf with the argument "hello, world\n". printf is a library function that prints output,in this case the string of characters between the quotes. A sequence of characters in double quotes, like "hello, world\n" , is called a character string or string constant. --------------------------------------------------------------------------- arguments One method of communicating data between functions is for the calling function to provide a list of values, called arguments, to the function it calls. --------------------------------------------------------------------------- /* my first c program */ Any characters between /* and */ are ignored by the computer; they may be used freely to make a program easier to under- stand. Comments may appear anywhere a blank or tab or newline can. --------------------------------------------------------------------------- variables A quantity that may assume any one set of values. VARIABLE is a storage location for a value. Each variable has a name and an associated value, which may change. In c all variables must be declared before they are used, usually at the beginning of the function before any executable statements. A declaration announces the properties of variables; it consists of a type name and a list of variables such as: int fahr, celsius; int lower, upper, step; The type int means that the variables listed are integers (integers any of the natural numbers, the negatives of these numbers, or zero). -------------------------------------------------------------------------- data types int integers. Means that the variables listed are integers. float floating point, i.e. numbers that may have a fractional part. char character - a single byte. short short integer. long long integer. double double-precision floating point. -------------------------------------------------------------------------- -------------------------------------------------------------------------- LINUX SOCKET PROGRAMMING QUE: p.52 adr_inet.sin_port = ntohs(0); adr_inet.sin_addr.s_addr = ntoh1(INADDR_ANY); adr_inet.sin_addr.s_addr = ntoh1(INADDR_LOOPBACK); adr_inet.sin_port = htons(900); adr_inet.sin_addr.s_addr = inet_addr("127.0.0.95"); p.3 http://www.quecorp.com/series/by_example/ this will link you to code in the book --------------------------------------------------------------------------------------- LINUX SOCKET PROGRAMMING SAM SEAN WALTON p.18 the telephone or caller (client) dest.sin_port = htons(PORT_TIME); /*select the port*/ p.38 dest.sin_port = htons(13); /*port#13 (time server)*/ notes: ch18 server kernel set up for networking,broadcasting, and multicasting http://www.samspublishing.com for code ----------------------------------------------------------------------------------------