Thread: C++/ C question
View Single Post

Member Since: Mar 15, 2007
Posts: 161
mystic_fm will become famous soon enough
Mac Specs: 17" MacBook Pro, 2.33GHz C2D, 2GB RAM

mystic_fm is offline
First off, "X" != "x", "Int" is not a defined type, "Printf" isn't a library function, etc. C is case sensitive; this won't even compile.

Even if these compile errors were fixed, the code would end up adding together three character pointer values (i.e., addresses of places in the computer's memory), the sum of which may not even fit into an integer type, and in any event is certainly not going to yield a meaningful integer sum. It most certainly is NOT adding together the integer representations of the command line arguments (1 + 5 + 7 == 13), which is apparently what the programmer was hoping for.

(By the way, argv[1] is addressing element #1 of a array named "argv". Element #1 is the index for the 2nd array element, since C arrays start at index 0.)
QUOTE Thanks