+ 1

Error in scanf() of c program

Could anyone please tell me why pressing 'enter' is making the third scanf() of my code not to work while the previous one is working? Thanks in advance :) https://code.sololearn.com/cxDIxVTfmgr6/?ref=app

25th Nov 2018, 12:40 PM
Sakif Uddowla
Sakif Uddowla - avatar
2 Respuestas
+ 12
You need to add a space in the third scanf function. You are taking Numeric inputs before, so sometimes it happens that compiler escapes the next input if it char type. #include <stdio.h> int main() { int n, m; char ch; scanf("%d", &n); scanf("%d", &m); scanf(" %c", &ch); printf("%d, %d_%c", n, m, ch); return 0; }
25th Nov 2018, 1:05 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 5
I'm not familiar with C but I edited your code. Check the comment. https://code.sololearn.com/cG2uYTZ5R6sT/?ref=app
25th Nov 2018, 12:58 PM
Lambda_Driver
Lambda_Driver - avatar