I was wondering if someone could please clarify some questions I have concerning the read()
function in Linux? Currently, I do not know how to view the buffer that is returned from the read() command. As of now, it is returning a seg fault and when I could get it to run it was returning values that were not present within the file I was trying to read. The text file: Testing a test.
So instead of getting testin (length 6) i would get testin{. I apologize if the question is confusing, if you'd like I will clarify more. Thanks for all your time and help!
int main(int argc, char *argv[]){
int fd = open("output_test.txt", O_RDWR | O_CREAT, 0666);
char *buffer;
char *copy;
// printf("%lu\n", strlen(buffer));
// write(fd, "testing", 7); //this automatically writes to
printf("%zd\n", read(fd, &buffer, 6));
printf("%lu\n", sizeof(buffer));
copy = buffer;
// printf("%lu\n", strlen(buffer));
printf("%s\n", copy);
}