perror() give seg. fault
Posted
by
Jack
on Stack Overflow
See other posts from Stack Overflow
or by Jack
Published on 2012-09-24T21:35:36Z
Indexed on
2012/09/24
21:37 UTC
Read the original article
Hit count: 133
After an error occurs, I call perror()
, naturally. But I'm getting a segmentation fault when I do this or printf("error: %s\n", strerror(errno));
I have no idea what is happing.
int fd;
if((fd = open(FILENAME, O_RDONLY)) == -1) {
perror("fbi");
exit(1);
}
for(;;) {
readed = read(fd, buffer, BUFSIZE);
if(readed == 0)
break;
if(readed == -1) {
perror("fbi"); // <- here's the error
exit(1);
}
How to fix this?
© Stack Overflow or respective owner