Thread: perror adding Success to end of error text

  1. #1
    Registered User
    Join Date
    May 2017
    Posts
    6

    perror adding Success to end of error text

    Not really sure what is going on here. The error message I have prints out and the program quits but it seems "Success" is being added to the end of my error message

    Code:
    void error(const char* msg)
    {
    perror(msg); exit(1);
    }
    Then when I have an error I do:
    Code:
    error("ERROR: input contains bad characters");
    The program exits but the message that is printed is:
    "ERROR: input contains bad characters: Success"

    Any idea why I am getting this success or how to fix this?

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,036
    Quote Originally Posted by potatoes1 View Post
    Not really sure what is going on here. The error message I have prints out and the program quits but it seems "Success" is being added to the end of my error message

    Code:
    void error(const char* msg)
    {
    perror(msg); exit(1);
    }
    Then when I have an error I do:
    Code:
    error("ERROR: input contains bad characters");
    The program exits but the message that is printed is:
    "ERROR: input contains bad characters: Success"

    Any idea why I am getting this success or how to fix this?
    Per perror - C++ Reference

    I think your errno is set to a value that is changed to success.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. perror undefined?
    By monkeycode in forum Windows Programming
    Replies: 4
    Last Post: 01-27-2012, 03:35 AM
  2. perror in C
    By vidya madala in forum C Programming
    Replies: 2
    Last Post: 11-11-2007, 08:40 AM
  3. adding text to top
    By kippwinger in forum C++ Programming
    Replies: 5
    Last Post: 07-26-2005, 01:25 AM
  4. errno --perror() problem
    By GanglyLamb in forum C Programming
    Replies: 10
    Last Post: 04-01-2003, 02:01 PM
  5. perror
    By C_Coder in forum C Programming
    Replies: 2
    Last Post: 11-11-2001, 10:45 AM

Tags for this Thread