Question: Can you show how to run code on the ubuntu terminal? Show all the steps and commands. The code reads from a stdin and sends

Can you show how to run code on the ubuntu terminal? Show all the steps and commands. The code reads from a stdin and sends to a stdout. Show how to do the stdin and stdout as well.

#include #include #include #define _GNU_SOURCE int main(char *argc, char* argv[]) { const char *file = argv[1]; FILE *ptr; char * line = NULL; size_t len = 0; ssize_t read; char filename[1000],c; char buffer[1000]; int i; ptr=fopen(file,"r"); if(ptr==NULL) { printf("cannot open the file "); exit(0); } while ((read = getline(&line, &len, ptr)) != -1) { char buffer[1000]; int found = 0; for(i=0;line[i]!='\0';i++){ if(found ==0 && line[i]==' ') { printf(" "); found = 1; continue; } if(line[i]!=' '){ if(line[i]==' '){ printf(" "); found = 1; } else{ printf("%c",line[i]); found =0; } } } } fclose(ptr); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!