error handlling in C

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • broli

    #1

    error handlling in C

    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.z eus", "r");
    if(zeus_file == NULL)
    {
    perror("File open error");
    return -1;
    }

    ............... ............... ............... .

    }

  • Ron Natalie

    #2
    Re: error handlling in C

    broli wrote:
    Is it generally a good idea to use perror() function to handle all the
    error situations ?
    >
    Perror doesn't handle anything. All it does is print an error message.
    Whether that is a good idea depends on who is going to be reading it.

    Most non-computer users are going to be scratching their heads
    with
    foo.txt: Not a typewriter

    where it might explain the world to a nuts and bolts computer geek.

    Comment

    Working...