I used strtok() to parse the string that I read in using cin.getline, but now I need to perform opperations on the strings that the *token is pointing to. I experimented quite a bit but I'm not getting what I want.
here's what I have done:
Now I have pointers to the strings, but I need to convert some of the strings to chars and some of them to ints. What can I do? Or should I say, what's the best thing to do?
I've tried things like:
here's what I have done:
Code:
~~
char *token1;
char *token2;
char *token3;
char string[100];
cin.getline(string[], 100);
token1 = strtok(Array, ",");
token2 = strtok(NULL, ",");
token3 = strtok(NULL, ",");
~~
Now I have pointers to the strings, but I need to convert some of the strings to chars and some of them to ints. What can I do? Or should I say, what's the best thing to do?
I've tried things like:
Code:
char temp_token1[] = (char) token1;
char temp_token2[] = (int) token2;