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

Popular posts from this blog

java - BeanIO write annotated class to fixedlength -

Using Java 8 lambdas/transformations to combine and flatten two Maps -

How to connect android app to App engine -