Hi bratulenu21,
char *p, s[300], sep[]=" * ";
this is the same as :
1 2 3 4
|
char *p;
char s[300];
char sep[]=" * ";
|
Just checking if that is what you want, it is probably fine, but your kind of declaration sometimes leads people into the trap of thinking they are all pointers. In this case they are, only because an array name is a pointer. Be aware you cannot do pointer arithmetic with an array name, unless you send to a function, in which case it is a local copy.
I try to avoid multiple declarations per line, - it can easily lead to errors.
If you want to set p to NULL, just leave out the dereference -
p=NULL;
I am not sure you need to do that though. Could you use the space char as delimiter - this will split the string into 3. I can't remember whether there is a function that will return an array with the 3 sub strings in it, or whether you just call strstr 3 times. Probably the latter for C, and the former for C++.
I found this example for C:
And this one for C++:
Hope all this helps.
I have been ninja'ed multiple times!! Must learn to type faster. Hope my advice was OK.