Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is a C program. Please add comment to each line of thecode explaining the function and add a screenshot of the output.You will need

Below is a C program. Please add comment to each line of thecode explaining the function and add a screenshot of the output.You will need to run the program in linux terminal.

#include #include int main(int argc, char *argv[]){   int ch, prev, row, col;  prev = EOF;  FILE *fp;  int y, x;  if(argc != 2)  {    printf("Usage: %s ", argv[0]);    exit(1);  }  fp = fopen(argv[1], "r");  if(fp == NULL)  {    perror("Cannot open input file");    exit(1);  }  initscr();                            /* Start curses mode */  getmaxyx(stdscr, row, col);           /* find the boundaries of the screeen */  while((ch = fgetc(fp)) != EOF)        /* read the file till we reach the end */  {    getyx(stdscr, y, x);                /* get the current curser position */    if(y == (row - 1))                  /* are we are at the end of the screen */    {      printw("<-Press Any Key->");        /* tell the user to press a key */      getch();      clear();                          /* clear the screen */      move(0, 0);                       /* start at the beginning of the screen */    }    if(prev == '/' && ch == '*')        /* If it is / and * then only                                         * switch bold on */        {      attron(A_BOLD);                   /* cut bold on */      getyx(stdscr, y, x);              /* get the current curser position */      move(y, x - 1);                   /* back up one space */      printw("%c%c", '/', ch);          /* The actual printing is done here */    }    else      printw("%c", ch);    refresh();    if(prev == '*' && ch == '/')      attroff(A_BOLD);                  /* Switch it off once we got *                                         * and then / */    prev = ch;  }  endwin();                             /* End curses mode */  fclose(fp);  return 0;}

Step by Step Solution

3.40 Rating (147 Votes )

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

In the G/M/1 model if G is exponential with rate show that = /.

Answered: 1 week ago

Question

22. Why is tPA not helpful in cases of hemorrhagepg105

Answered: 1 week ago