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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -