Topics for a C lecture for people who have already tried themselves Why C? What is C? CPP is Object Oriented Several C basics - Controlling the flow ---------------- if , ternary if goto LABEL do vs. while continue vs. break switch,case,default CPP - C Pre Processor ----------------------- #define #ifdef #ifndef #if # vs. ## macros: continuation line using paranthesis in a macro debugging inside a macro alighnment of a macro #include headers: protection. standartization of protection. "" vs. <> definition of include path. The -I switch. mixing architectures - location of header files of various c compilers differs. Compilation switches ---------------- debug optimize profile -Werror -Wall, not all is in all gcc extentions ------------- inline functions ... Declaring variables ---------------- Allowed location for declaring variables Good location for that initialization vs. optimization namespaces. overlapping of namespaces. compilation switches in gcc - overlapping, unused variables. why they are dangerous. the dangers in comparisons (NULL==a vs. a==NULL). if (i=4) not accepted in some compilers to protect you, put ((i=4)). types ----- types of c built in variables arch dependent types the concept of pointers functions --------- How to define a function static the return value, void return value using the return value for errors. note on throw/catch. library functions. checking return value of system, library functions. comments --------- c style c++ style doxygen new types: ------------ enum numerical value of enum. what is it? is it good to use? structs definition of struct structs in a connected list named structs and enums vs. un-named typedef pointers --------- the address of a variable the variable an adress points to passing a pointer to a function - in the calling function in the accepting function's definition inside the accpeting function an array mem arrangement of an array a double array compared to a pointer to a pointer faking the stack ---------- global vars static variables efficiency ---------- cache misses time to fetch vs. time to compute drop efficiency in the face of readability, the compiler will optimize anyway. const ---- const variables vs. #define why and how to use const when calling a funciton dynamic memory -------------- stack, heap and data where, what for sizes of said memory parts. smearing the stack pointer basic allocate and free why free? garbage collection languages memory violation: leak, smear (r/w) pointer arithmethics self mem management vs. alloc's management the intervals tree memcheck tools: -------------- safe allocate and free (ckfree, ckalloc by Nadav Har'El) third valgrind zmalloc files ----- fopen, fclose, return values fprintf, fscanf. the printf format. strings ---- what is a string? NULL terminated string vs. fortran string vs. pascal string strncat,snprintf vs. strcat,sprintf system ------ system calls calling system help ------ man 3 info K&R standards --------- K&R ANSI C89 C99 debug ------- debug symbols gdb ladebug, dbx ddd xgdb IDEs ---- syntax highlighting, indentation invoking compilation connecting brackets jgrasp xemacs vim argc, argv. pointer to function ----Good Programming--- prepare to add more variables to the model make the interfaces not change with more vars make the definitions in one place string sizes should be fixed in one place if not possible - compare fixed sizes in run time. collect all operations on an animal to one place, call it from there when executed. THE BOOK!!!