Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Explain each line of code. #include #include int main(int argc, char *argv[]) { int ch, prev, row, col; prev = EOF; FILE *fp; int y,

Explain each line of code.

#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();

getmaxyx(stdscr, row, col);

while((ch = fgetc(fp)) != EOF) {

getyx(stdscr, y, x);

if(y == (row - 1))

{

printw("<-Press Any 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);

getyx(stdscr, y, x);

move(y, x - 1);

printw("%c%c", '/', ch);

}

else

printw("%c", ch);

refresh();

if(prev == '*' && ch == '/')

attroff(A_BOLD);

prev = ch;

}

endwin(); /* End curses mode */

fclose(fp);

return 0;

}

Step by Step Solution

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

Students also viewed these Databases questions

Question

If P (A) = 0.4, P(B) = 0.9 and P(A and B) =0.1, Find P(A or B).

Answered: 1 week ago