December 6th, 2012, 01:06 PM
December 6th, 2012, 01:29 PM
"%s" specifies a string, not a decimal integer (which would instead be "%d"). So you're forcing printf to treat those three decimal values as pointers to strings -- ie, as memory addresses. Memory addresses that low would most definitely be in an area of memory that's reserved for the operating system, so the operating system protects itself from you by terminating your program with extreme prejudice. For that matter, trying to access any memory location that's not assigned to you, including those of other processes, will also cause your program to crash (the error code / message should say something about an "access error" or a "segmentation fault", AKA "segfault").
Use the proper format specifiers in printf instead.
December 6th, 2012, 01:44 PM
Thanks dwise, I swear I started off with %d but I changed it because I was getting a compile error earlier. Obviously it was because of something else. Thanks again.