0

Why my 2nd char input line in do_while loop getting skipped?

Can anyone help? My 2nd char input line in do_while loop getting skipped . . . here's the code: #include <stdio.h> main() { char C,A; printf("\n ASCII Converter\n"); do { printf("\n Enter the Char: "); C=getchar(); printf(" ASCII CODE/VALUE: %d\n",C); printf("Again? y/n\n\n"); scanf("%c",A); }while (A=='y' || A=='Y'); if(A=='y' || A=='Y') return 0; }

25th Jan 2019, 3:45 PM
Md Faridul Islam
Md Faridul Islam - avatar
8 Answers
+ 2
scanf needs a reference. scanf("%c", &A);
25th Jan 2019, 4:40 PM
Zen
Zen - avatar
+ 2
Try entering "cyan" (without the quotes) when submitting inputs.
25th Jan 2019, 4:57 PM
Zen
Zen - avatar
+ 1
Could you please put the code on Code Playground and put the link in this thread? It would be much easier to debug.
25th Jan 2019, 4:46 PM
Zen
Zen - avatar
+ 1
There is nothing wrong with this code. What's the problem? scanf doesn't print anything if this is what you have in mind.
25th Jan 2019, 4:51 PM
Zen
Zen - avatar
0
updated: #include <stdio.h> main() { char C,A; printf("\n ASCII Converter\n"); do { printf("\n Enter the Char: "); scanf("%c",&C); printf(" ASCII CODE/VALUE: %d\n",C); printf("Again? y/n\n\n"); scanf("%c",&A); }while (A=='y' || A=='Y'); if(A=='y' || A=='Y') return 0; } still not working :/
25th Jan 2019, 4:43 PM
Md Faridul Islam
Md Faridul Islam - avatar
25th Jan 2019, 4:48 PM
Md Faridul Islam
Md Faridul Islam - avatar
0
the #12 line, where it should've taken an char input y or something else then repeat the loop, it doesn't. No matter what, I cant make the loop repeat.
25th Jan 2019, 4:55 PM
Md Faridul Islam
Md Faridul Islam - avatar
0
getting somewhere now... ayby shows the value of a then y repeats the loop shows the value of b then y repeats the loop.
25th Jan 2019, 5:11 PM
Md Faridul Islam
Md Faridul Islam - avatar