|
|
On Mar 28, 5:02 pm, broli <Brol...@xxxxxxxxx> wrote:
> Is it generally a good idea to use perror() function to handle all the
> error situations ?
>
> For eg in one of my modules I have used it extensively.
>
> int reader()
> {
> FILE *zeus_file;
> ....................
> .....................
>
> zeus_file = fopen("sphere.zeus", "r");
> if(zeus_file == NULL)
> {
> perror("File open error");
> return -1;
> }
>
> ..............................................
>
> }
If you afterwards decide to use another stream than strerr, then yes
it's bad.
Use fprintf(stream, %s%s\n", "File open error", strerror(errno))
strerror() is declared in <string.h>
|
|