#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main() {
char buf[15];
char *buf1 = "CE_and_IST";
char buf2 = 'z';
int fd = open("myfile", O_RDWR);
lseek(fd, 10, SEEK_SET);
int n = read(fd, buf, 10);
printf("%d\n", n);
n = write(fd, (const void *)buf1, 10);
printf("%s\n", buf);
lseek(fd, 0, SEEK_SET);
close(1); dup(fd); close(fd);
n = write(1, (const void *)&buf2, 1);
close(1);
return 0;
}
and the contents of "myprofile" is Welcome_to_CIS
so the output for this code is, and I'm really confused, is 5 come from 15 minus 10, I thought the length of the code is 15. like what does exactly this code do?
5
_CIS
and the contents of "myprofile" is after execution is
Zelcome_to_CIS
CE_and_IST
How did they get to this?