Wednesday, August 31, 2005

Memory Locations
For curiosity, you might try printing out the locations s1 and s2 in
the different versions by using printf's %p; you would likely see that
malloc, read-only strings, and stack-based arrays are all in distant
parts of memory.

Wednesday, August 24, 2005

Don't foreget when you define a pointer to define what it points to !
struct mystuct * s;
You can't say s->v1 = ... ; as you didn't say s equals what !!
you 've to say first s = new pointer, or s = return of a function ...

Don't forget to deallocate memory of a pointer received from a function return. (you didn't allocate that memory but it was allocated by the function you called)

Note That:
In a function, you have to return an allocated pointer (or edit a pointer passed to it as an argument) and you CANNOT return address of an object, cuz the object is locally defined and will be destroyed at the function termination, so the address will be pointing to garbage.

Also, it is NOT RECOMMENDED to pass solid objects through functions, especially if they are large size objects or structures as it is overhead on the stack

Wednesday, August 10, 2005

Google capacity:

256 characters
32 words

Thursday, August 04, 2005

"warning: passing arg 2 of `signal' from incompatible pointer type"

This warning appears when the signal handler function is not void