Results 1 to 3 of 3
Hi group,
I am fighting with sscanf again. I am trying to use the pointer update
feature "%p" and it is not working as expected.
The code looks like this:
...
- 02-15-2008 #1Just Joined!
- Join Date
- May 2005
- Posts
- 15
trouble with sscanf
Hi group,
I am fighting with sscanf again. I am trying to use the pointer update
feature "%p" and it is not working as expected.
The code looks like this:The output looks like this:
int
main( int argc, char* argv[] ) {
int RC=0;
int I1,I2,I3,I4;
char* _P;
char Buffer[] = "1\n2\n3\n4\n xxzzy The rest of this ! \n";
char Temp[255];
strcpy(Temp,Buffer);
_P = Temp;
RC=sscanf( _P, "%d\n%d\n%d\n%d\n%p", &I1, &I2, &I3, &I4, _P );
printf( "RC = %d %d %d %d %d New=%s\n\n", RC, I1, I2, I3, I4, _P );
strcpy(Temp,Buffer);
_P = Temp;
RC=sscanf( _P, "%d\n%d\n%d\n%d\n%s", &I1, &I2, &I3, &I4, _P );
printf( "RC = %d %d %d %d %d New=%s\n\n", RC, I1, I2, I3, I4, _P );
return;
What I am trying to do is update the pointer to the data after the
RC = 4 1 2 3 4 New=1
2
3
4
xxzzy The rest of this !
RC = 5 1 2 3 4 New=xxzzy
conversion so that _P pointers to "xxzzy The rest of this !"
Any ideas?
- 02-16-2008 #2
Format %p in sscanf() is not a pointer update feature. It attempts to read the value of some pointer from the input. The closest to what you want is the %n format.
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.
- 02-16-2008 #3Just Joined!
- Join Date
- May 2005
- Posts
- 15


Reply With Quote
