|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MaxT (26) | |||
|
Ok So I want to be be able to grab the IP in human readable form from a device. (I know there are many ways of doing this) I've come across something odd though... after this section of code my program terminates prematurely...
As in it carries out the final printf before quitting .... the next line after that is printf("gotpastsetup"); and that is not run....(after that there is a whole bunch of other stuff) I'm extremely confused why is it exiting? | |||
|
|
|||
| kevinchkin (448) | |||||
I guess it's because you are not allocating any memory for char *bufAnd since no memory has been allocated it gives segmentation fault when you try to print it. Try this:
OR
Hope this helps ! | |||||
|
|
|||||
| MaxT (26) | |
| Hah thanks wow I feel like an idiot now ^_^ | |
|
|
|
| MaxT (26) | |
|
Ok Just one more question. why would the program run fine inside an IDE like codeblocks but once I compile it and run it from the terminal it immediately segfaults o_0 (I'm a bit new to programming under a unix environment,) | |
|
|
|
| PanGalactic (1558) | |
| That's usually due to bugs inside your code that are dependent on memory layout. This is very typical when an invalid or uninitialized pointer is dereferenced. | |
|
|
|
| MaxT (26) | |
| Found it, I was passing args to main and using them without checking to see if any args had been passed or not. | |
|
|
|