Page 1 of 1

#include #include #include #include #include #include #inlcude #include #include struct pair { }; int myErr(int

Posted: Tue Jul 12, 2022 8:22 am
by answerhappygod
Include Include Include Include Include Include Inlcude Include Include Struct Pair Int Myerr Int 1
Include Include Include Include Include Include Inlcude Include Include Struct Pair Int Myerr Int 1 (23.17 KiB) Viewed 35 times
Need this program corrected and compile the outputbelow using time interval system calls. The first form is thecharacter - integer pairing and should be displayed as (character,integer). The other form can be thought of as the pairings decodedform; the character - integer pairing ('b',6) would be decoded as'bbbbbb'. Unlike before I used sleep or nanosleep for the timedelay, this program will use an interval timer.
Here is the output:
Include Include Include Include Include Include Inlcude Include Include Struct Pair Int Myerr Int 2
Include Include Include Include Include Include Inlcude Include Include Struct Pair Int Myerr Int 2 (517.41 KiB) Viewed 35 times
#include #include #include #include #include #include #inlcude #include #include struct pair { }; int myErr(int val, const char *msg) { } char val; short int cnt; } if (val { == } return val; perror (msg); exit(exit_FAILURE); int main(int argc, char *argv[]) { -1) int i = 0; char fname[1024] int fd; int numRead; fd = struct pair arr; struct timespec ts; = if (argc > 1) strcpy(fname, argv[1]); ts.ts_sec = 1; ts.tv_nsec = 0; while ((numRead { myErr (open(fname, O_RDONLY), "open"); "image.dat"; } close(fd); = read (fd, &arr, sizeof(struct pair))) > 0) printf("%c %2d :: ",arr.val, arr.cnt); for (i = 0; i < arr.cnt; i++) { printf("%c", arr.val); } printf("\n"); nanosleep (&ts,NULL);
tnt myerr(int val, const cnar { } if (val == -1) { perror(msg); exit(EXIT_FAILURE); } return val; int main(int argc, char *argv[]) { (j, 16): jjjjjjjjjjjjjjjj (x, 11): XXXXXXXXXXX (s, 18) :: (i, 12): iiiiiiiiiiii (t, 15) :: 8) :: (v, (n, 15) :: (s, 14): (t, :-/programs/program4$ gcc read.c :-/programs/program4$ ./a.out ssssssssssssssssss (f, 12) :: ffffffffffff (u, (h, 14) :: hhhhhhhhhhhhhh vvvvvvvv 6) :: uuuuuu ttttttttttttttt struct pair arr; struct timespec ts; if (argc > 1) strcpy(fname, argv[1]); ts.tv_sec = 1; ts.tv_nsec = 0; 5) :: iiiii 7) :: XXXXXXX 9): yyyyyyyyy nnnnnnnnnnnnnnn ssssssssssssss int i = 0; char fname[1024] = "image.dat" (X, int fd; (y, (s, 15) :: sssssssssssssss int numRead; (0, 6) :: 000000 fd = myErr (open(fname, O_RDONLY), "open"); while ((numRead = read(fd, &arr, sizeof(struct pair))) > 0) I