How to read the standard input into string variable until EOF in C?
问题 I am getting "Bus Error" trying to read stdin into a char* variable. I just want to read whole stuff coming over stdin and put it first into a variable, then continue working on the variable. My Code is as follows: char* content; char* c; while( scanf( "%c", c)) { strcat( content, c); } fprintf( stdout, "Size: %d", strlen( content)); But somehow I always get "Bus error" returned by calling cat test.txt | myapp , where myapp is the compiled code above. My question is how do i read stdin until