The variable swhois has been previously defined in the program as 'static char *swhois[50]; '.

The line in question is "mywhois = strtok(NULL, ":");" as it's reading in 18 characters from the file properly but doesn't continue reading to the end of the line. It is intended to load something like this example '80:somepassword:some description with spaces' from the file and assign it to variables. Everything works (with numerous warnings) except that at the end of it all, 'myswhois' only contains 18 (of say 30) characters. Is there a way i can make strtok() read in more characters? If not, what should I use instead to read the line in?

Thanks for your response. If i changed it from an array to just static char *swhois; Would that make any difference? Also, the line variable 'mywhois' only contains 19 characters (instead of 18 in the original post, sorry) when reading in via strtok(). What insight could you share on that? It is, so far, copying to 'swhois' perfectly fine.

Currently you have 50 fingers, pointing to nothingness (that is, you have pointers but nothing for them to point to). If you change it to just a static char*, then you still don't have any memory, but just one finger pointing to nothingness. If you believe you are supposed to have a static buffer of memory, then you want

Thanks for your response. If i changed it from an array to just static char *swhois; Would that make any difference? It is, so far, copying to 'swhois' perfectly fine.

However it is not copying to swhois fine. char* swhois is just a pointer. You need to actually allocate space to hold anything in it, as Salem already said. What you are seeing is undefined behavior. The easiest way to do this is just make swhois a char array, e.g. char swhois[50];

You need to revisit strtok(). Read this. I would suggest you make a simple program and get the strtok part working first, then include it into your actual program.

Originally Posted by anduril462

Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....

Originally Posted by quzah

..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.

Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

I appreciate everyone's input on this matter, it has helped out greatly. Evidentally, there was another function that broke the buffer up and allocated memory into seperate variables before the function I wrote is called. It wasn't copying the entire buffer to the array in the other function and that's why I was missing information.. Again, thanks to everyone who responded, I appreciate your time.