sscanf() return value

Hello everyone!

I'm having trouble using the output of strtok() as an input to sscanf().

I know the first returns a char * and the second takes for its first argument the same type.

My problem is: (1) Is there a difference between these types?:
1
2
char * pa;
char pb[10];


(2) When getting a desired output using p = strtok(...) (I know so because I used the cout << p ), I get an overflow when dereferencing p i.e. cout << *p or cout << p[0](program has stopped running right after it displayed the first character of p).
sample code:
1
2
3
4
p = strtok(mystring, " ");
char * name; /*also tried using char name[10]*/
int age;
sscanf(p, "My name is %s and I am %d", name, &age);
Last edited on
Problem solved...
Topic archived. No new replies allowed.