Reputation: 177
I have a string which captures details stored in data
User 6%, System 18%, IOW 0%, IRQ 0%
What i am doing is
sscanf(data,"User %d,System %d,IOW %d,IRQ %d",&user,&sys,&iow,&irq);
I am getting wrong output . why ? Is is like i am missing something ?
Upvotes: 0
Views: 57
Reputation: 875
You have wrong output because you input string is like:
User 6%, System 18%, IOW 0%, IRQ 0%
But you try to scan a string like:
User 6, System 18, IOW 0, IRQ 0
Upvotes: -2
Reputation: 212979
You left out the %
symbols and some spaces - try:
sscanf(data,"User %d%%, System %d%%, IOW %d%%, IRQ %d%%",&user,&sys,&iow,&irq);
Upvotes: 5