c - Loop through user input with getchar -
i have written small script detect full value user input getchar()
function in c. getchar()
returns first character tried loop through it... code have tried myself is:
#include <stdio.h> int main() { char = getchar(); int b = strlen(a); for(i=0; i<b; i++) { printf("%c", a[i]); } return 0; }
but code not give me full value of user input.
you can looping part way
int c; while((c = getchar()) != '\n' && c != eof) { printf("%c", c); }
Comments
Post a Comment