J
Joachim Schmitz
Hi folks
What would be the expected and correct output of the following
#include <stdio.h>
int main (void)
{
char buffer1[] = "(10,20,30)";
char buffer2[] = "(10,20,30 )"; /* add two white spaces between 30
and ) */
int var1, var2, var3;
int i = 11111;
int j = 22222;
sscanf (buffer1,"(%d,%d,%d)%n",&var1,&var2,&var3,&i);
printf ("%s -> %d\n",buffer1,i);
sscanf (buffer2,"(%d,%d,%d)%n",&var1,&var2,&var3,&j);
printf ("%s -> %d\n",buffer2,j);
return 0;
}
On one platform I get:
(10,20,30) -> 10
(10,20,30 ) -> 12
on another I get:
(10,20,30) -> 10
(10,20,30 ) -> 22222
i.e. j is left unmodified.
Which is correct?
Bye, Jojo
What would be the expected and correct output of the following
#include <stdio.h>
int main (void)
{
char buffer1[] = "(10,20,30)";
char buffer2[] = "(10,20,30 )"; /* add two white spaces between 30
and ) */
int var1, var2, var3;
int i = 11111;
int j = 22222;
sscanf (buffer1,"(%d,%d,%d)%n",&var1,&var2,&var3,&i);
printf ("%s -> %d\n",buffer1,i);
sscanf (buffer2,"(%d,%d,%d)%n",&var1,&var2,&var3,&j);
printf ("%s -> %d\n",buffer2,j);
return 0;
}
On one platform I get:
(10,20,30) -> 10
(10,20,30 ) -> 12
on another I get:
(10,20,30) -> 10
(10,20,30 ) -> 22222
i.e. j is left unmodified.
Which is correct?
Bye, Jojo