A
Artemio
Dear folks,
I need some help with using the sscanf() function. I need to parse a
string which has several parameters given in a "A=... B=... C=..." way,
and each has a different type (one is a text string, another is a
decimal, next one is float, etc.).
I have GCC 4.0.1 on Mac OS X Tiger.
Here is an example of what I am trying to do.
<code>
char A[16];
int B;
float C;
sscanf( "A=Test B=25 C=3.14159", "A=%s B=%d C=%f", A, &B, &C);
printf("%s %d %f",A,B,C);
</code>
This prints "Test 0 0.0000"
I also tried this:
<code>
....
sscanf( "A=Test B=25 C=3.14159", "A=%s",A);
sscanf( "A=Test B=25 C=3.14159", "B=%d",&B);
sscanf( "A=Test B=25 C=3.14159", "C=%f",&C);
....
</code>
but this gives same results...
What am I doing wrong? :-/
Thanks for any help.
Artemiy.
I need some help with using the sscanf() function. I need to parse a
string which has several parameters given in a "A=... B=... C=..." way,
and each has a different type (one is a text string, another is a
decimal, next one is float, etc.).
I have GCC 4.0.1 on Mac OS X Tiger.
Here is an example of what I am trying to do.
<code>
char A[16];
int B;
float C;
sscanf( "A=Test B=25 C=3.14159", "A=%s B=%d C=%f", A, &B, &C);
printf("%s %d %f",A,B,C);
</code>
This prints "Test 0 0.0000"
I also tried this:
<code>
....
sscanf( "A=Test B=25 C=3.14159", "A=%s",A);
sscanf( "A=Test B=25 C=3.14159", "B=%d",&B);
sscanf( "A=Test B=25 C=3.14159", "C=%f",&C);
....
</code>
but this gives same results...
What am I doing wrong? :-/
Thanks for any help.
Artemiy.