C infinite loop issue when prompting -
Why are an infinite loop without prompting re-users in the code
< Code> #include & lt; Stdio.h & gt; #include & lt; String.h & gt; # Include & lt; Ctype.h & gt; Zero to_rot13 (four * values); Int main () {four words [1024]; Printf ("C-rote 13 \ nSome code codes or decoded \ n"); While (1) {printf (":"); Scanf ("% [^ \ n] s", word); To_rot13 (& amp; शब्द); Printf (":% s \ n", word); } Return 0; } Zero to_rot13 (char * value) {unsigned int x; (X = 0; value [x]! = '\ 0'; x ++) {if ((value [x]'A') (value [x] & gt; 'Z' & amp; ; Value (value [x] & gt; 'z')) {} and if (tolower (value [x]) <= 'm') {value [x] = value [x] + 13;} else {Value [x] = value [x] - 13;}}} I would like to prompt the user again that I can not be more accurate.
scanf ("% [^ \ n] s", word);
Leaves the new line in the input buffer, so the next
scanf does not immediately read any input, because the first
char is a new line in the left buffer Land you must remove the new line from the input buffer.
int c; do {c = getchar ();} while (c! = '\ N' & amp; c! = EOF) ;; (C == EOF) {exit (EXIT_FAILURE); // Input Bourke}
In addition, keeping in mind the compiler's warning and the
word To
to_rot13 .
Comments
Post a Comment