+ 1
My while statement is not functioning properly. Please explain why. It doesnt wait for taking my input for char rep.?
#include <stdio.h> using namespace std; char rep; int main() { while (rep!='n') { printf ("the loop is on\n Do you want to repeat? y/n \n"); scanf("%n", &rep); } } it doesnt wait for taking my input into rep, the code repeats automatically. why?
4 Answers
+ 1
so what should i write instead?
+ 1
so what should i write instead?
0
%n bro ...its character scanf mai dekh
0
%c instead %n ...char:%c