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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -