#include #include int main(int argc, char *argv[]) { FILE *fd; char c; if(argc==1) fd=stdin; else XXXXXXXXXXif((fd = fopen(argv[1], "r"))==NULL){ fprintf(stderr, "Error opening %s, exiting\n",...

1 answer below »
This is the assignment in UNIX and C. Do not copy from online website or chegg.


#include #include int main(int argc, char *argv[]) { FILE *fd; char c; if(argc==1) fd=stdin; else if((fd = fopen(argv[1], "r"))==NULL){ fprintf(stderr, "Error opening %s, exiting\n", argv[1]); exit(0); } while( (c=getc(fd)) != EOF) putc(c, stdout); exit(0); }
Answered Same DayJun 30, 2021

Answer To: #include #include int main(int argc, char *argv[]) { FILE *fd; char c; if(argc==1) fd=stdin; else...

Swapnil answered on Jul 01 2021
142 Votes
87360/1/1.c
#include
#include
int main(int argc, char *argv[])
{
    int file1,k;
    char x;
    i
f(argc==1)
    {
        file1=1;
    }
    else
    {
        file1 = open(argv[1], O_RDONLY);
        if(file1<0)
        {
            write(2,"File not opened", 15);
            exit(1);
        }    
    }
    while((k = read(file1, &x, 1)) !=-1)
    {
        write(2, x, 1);
    }
    close(file1);
    return 0;
}
87360/1/mycat-4m2tzokt-jeby2tsk.c
#include
#include
int main(int argc, char *argv[])
{ FILE *fd;
char c;
if(argc==1)
    fd=stdin;
else
if((fd = fopen(argv[1], "r"))==NULL){
        fprintf(stderr, "Error opening %s, exiting\n", argv[1]);              exit(0);
    }
while( (c=getc(fd)) != EOF)
    putc(c, stdout);
exit(0);
}
87360/2/2.c
#include
#include
#define MAX 2000
#define LINESIZE 100
void r_Content(char* filein, char* fileout)
{
FILE* fp = fopen(filein, "r");
FILE* fOut = fopen (fileout, "w");
if (fp == NULL || fOut == NULL)
{
printf("Unable to open file\n");
return;
}
char buf[LINESIZE];
int l_Add[MAX], s = 0, len, i=0;
l_Add[i]...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here