0

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 ?

2 Answers 2

5

You left out the % symbols and some spaces - try:

sscanf(data,"User %d%%, System %d%%, IOW %d%%, IRQ %d%%",&user,&sys,&iow,&irq);
Sign up to request clarification or add additional context in comments.

Comments

-2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.