+ 2
C scanf() question (no. 2) [SOLVED]
Consider this code: https://code.sololearn.com/cqsDiKu82DKf/?ref=app Why is the newline character still there after giving a 2-line input? Shouldn't it be consumed by "%*c" ?
5 Respostas
+ 5
I don't think you need the 's' after the set. It will try to match a corresponding 's' in the input stream, instead of belonging to the set, and therefore cause scanf() to abort early when encountered:
https://stackoverflow.com/questions/33971044/scanf-limited-character-set
+ 3
Calvin,
Shadow is right, so instead of
scanf("%[^\n]s %*c %s", a, b);
You can try
scanf("%[^\n]%*c %s", a, b);
Tried it, and seems to be working fine
+ 2
Do you give name inputs on single line or in separate line?
+ 1
Ipang It's separate.