Question: C PROGRAMMING EASY [only in C ] NOTES: Headers that can be use are only as follows: stdio.h, string.h, unistd.h, stdlib.h, sys/stat.h, sys/types.h, sys/wait.h, ctype.h,

C PROGRAMMING EASY [only in C ]

NOTES:

Headers that can be use are only as follows: stdio.h, string.h, unistd.h, stdlib.h, sys/stat.h, sys/types.h, sys/wait.h, ctype.h, signal.h, fcntl.h

-Then here are some other stuffs to consider:

  • MaxLine: 80, MaxArgc: 80, MaxJob: 5

  • Use both execvp() and execv() to allow either case.

    execvp() : Linux commands {ls, cat, sort, ./hellp, ./slp}. execv() : Linux commands {/bin/ls, /bin/cat, /bin/sort, hello, slp}.

Code this below

Create 2 programs, add.c and counter.c, and compile them

int main(int argc, char * argv[]){ int n = atoi(argv[1]); printf("%d ", n+2); // print n+2 return 0;

}

int main() {

unsigned int i = 0; while(1) {

printf("Counter: %d ", i); i++; sleep(1);

} }

$gcc add.c -o add $gcc counter.c -o counter

Now we have compiled executables, add and counter. ^Z in below == ctrl-Z

C PROGRAMMING EASY [only in C ] NOTES: Headers that can be

prompt> add 4 6 prompt> add 4 > out.txt prompt> cat out.txt 6 prompt> counter Counter: 0 Counter: 1 ^Zprompt> jobs [1] (2744) Stopped counter prompt> fg %1 Counter: 2 Counter: 3 Counter: 4 AZprompt> jobs [1] (2744) Stopped counter prompt> fg 2744 Counter: 5 Counter: 6 Counter: 7 ^Zprompt> jobs [1] (2744) Stopped counter prompt> kill %1 prompt> jobs prompt> quit

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!