Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Char pointers that point to constant strings is fine (generally speaking - however, for the structure you described in the initial post here, you DO need to have a char array). You should really use "const char *var = "Some string";" - that way the compiler will tell you if you try to modify such a string - which will most likely cause some sort of problem - strange results later on or a crash.
Char pointers to variable content is more complex, as you need to somehow allocate memory, and both that and char arrays requires that you know the maximum length of the final content (and that you validate that you are not going beyond that maximum length, as that will store data into "something elses memory" which leads to corrupted data content and/or a crash - or if you are really "lucky" crash the program directly as you go beyond the limit).
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Thanks for the help guys. Mats I have updated my code to use arrays instead of pointers now and it seems like a good habit to use 'const char' when using pointers this way as you mentioned, thanks.
Last edited by Subsonics; 01-07-2009 at 04:44 PM.