I was wondering if anyone could help - I'm trying to split up a char* that contains a string, something like "Stephen10:11:0002/07/2012Hi there"
I'm trying to split it up so it gets the position of the first * then the second, and stores whats between them in name and so on - so far I can get the positions of the *'s with
const char* msgStart = strchr (msg, '*'); const char* nameEnd = strchr (msgStart+1, '*');
const char* name = msgStart+1;
but this puts the rest of the message in the name variable. I've tried using strncpy and memcpy to assign name;
char* nameBuffer = 0; strncpy (nameBuffer, msg, nameEnd - msgStart);
But I jsut get a seg fault :S is there any way to split up a char* this way (I know I could just copy it to a std::string and do this alot quicker and easier, but I'm just trying to learn how to do it the hard way :))
Any help is much appreciated as always!!