I'm parsing an input of string using sscanf. I found that the way sscanf behaves is funny.
My input of String looks as follows :-
1000Prasun K 1004BANGL0
Initially I used the following command to parse the input :-
scanf (acEmpRecord, "%d%[^0-9]25s%d%5s%d",
&iEmpId, acEmpName, &iDeptCode, acLocation, &iTelExt);
and I get -> 1 1000 Prasun K ╠╠╠╠╠╠╠╠Prasun K -858993460.
Supposedly, my the output should look like :-
1 1000 Prasun K BCMD BANGL -
To solve the above problem, I've removed 25s from the sscanf and the command look likes the below statement.
sscanf (acEmpRecord, "%d%[^0-9]%d%5s%d",
&iEmpId, acEmpName, &iDeptCode, acLocation, &iTelExt);
I managed to get the intended output.
Sunday, November 30, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment