nerdLife wrote:I love this book. ... Here's what the pointer.c (from page 44) looks like in vim...
Even though this is quite an old post, I don't see any replies.
1. When you try to run your code with ./pointer.c, since it it not a compiled program, your terminal will interpret it as a shellscript and fail because it's not a correct script.
2. When you compile with gcc, the warnings you get are because what you are trying to do is dangerous. When you do a printf without formatting, printf(pointer); in your case, a format string can be exploited. The correct way is to use a format like printf("%s", string) or printf("%i %i %i %i", integer1, integer2,...). Warnings at compilation does not affect the compilation and you should still get a working output (a.out if no output is specified)
What you should do:
gcc pointer.c -o pointer
./pointer
Format strings are covered in the book, as far as i remember.