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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -