Question: Hello, I need help with this problem in C. I am trying to get the code to do what the instructions say but also with
Hello, I need help with this problem in C. I am trying to get the code to do what the instructions say but also with it using STDIN and STDOUT and it has to be that the user can type in ./a.out MY CODE SO FAR(NEED TO KEEP WHAT I HAVE FOR STDIN AND STDOUT AS I AM TRYING TO USE THIS METHOD) #include #include #define MAXLEN 100 int main(int argc, char **argv) { //freopen(argv[1], "r" , stdin); int bufferlen=MAXLEN; char *buffer=malloc(MAXLEN); if(buffer==NULL)//To check if NULL { printf("ERROR: Corrupt malloc. Terminating. ");//Prints error message return 1;//Terminates program with 1 value } while(fgets(buffer,bufferlen,stdin)!=NULL)//Will take in first line and put it into buffer { printf("%s",buffer);//Print the strings scanf("%s",buffer); if (ferror(stdin))//In case of error { printf("Error on stdin. "); break; } } } INSTRUCTIONS 
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
