perror(3) Library Functions Manual perror(3)NAME
perror - Writes a message explaining the current setting of errno
LIBRARY
Standard C Library (libc.a, libc.so)
SYNOPSIS
#include <stdio.h>
void perror(
const char *string);
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
perror(): ISO C, POSIX.1, XPG4, XPG4-UNIX
Refer to the standards(5) reference page for more information about industry standards and associated tags.
PARAMETERS
Points to a string containing the name of the program that caused the error.
DESCRIPTION
The perror() function writes a message on the standard error stream that describes the current setting of the external variable errno. The
error message includes the string pointed to by the string parameter, followed by a : (colon), a blank, the system message string, and a
newline character. The string parameter string should point to the name of the program that caused the error.
To get the system error message string for use by a program, as opposed to displaying it on standard error, use the strerror() function.
For more information, see strerror(3).
RELATED INFORMATION
Routines: printf(3), strerror(3)
Standards: standards(5) delim off
perror(3)
Check Out this Related Man Page
perror(3C) Standard C Library Functions perror(3C)NAME
perror, errno - print system error messages
SYNOPSIS
#include <stdio.h>
void perror(const char *s)
#include <errno.h>
int errno;
DESCRIPTION
The perror() function produces a message on the standard error output (file descriptor 2) describing the last error encountered during a
call to a system or library function. The argument string s is printed, followed by a colon and a blank, followed by the message and a NEW-
LINE character. If s is a null pointer or points to a null string, the colon is not printed. The argument string should include the name
of the program that incurred the error. The error number is taken from the external variable errno, which is set when errors occur but not
cleared when non-erroneous calls are made. See Intro(2).
In the case of multithreaded applications, the -mt option must be specified on the command line at compilation time (see threads(5)). When
the -mt option is specified, errno becomes a macro that enables each thread to have its own errno. This errno macro can be used on either
side of the assignment as though it were a variable.
USAGE
Messages printed from this function are in the native language specified by the LC_MESSAGES locale category. See setlocale(3C).
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO Intro(2), fmtmsg(3C), gettext(3C), setlocale(3C), strerror(3C), attributes(5), standards(5), threads(5)SunOS 5.11 12 Jul 2007 perror(3C)
Dear all,
I use perror in order to print an error message to the standar error. For example
if a C program is called without its two necessary command line parameters
then :
if (argc != 3)
{
perror("use: ./myProgram <source file> <target file>\n");
return 1;
}
Now the... (2 Replies)
here the program gives a odd result:
#include <stdio.h>
int main(){
perror("first");
perror("next");
return 0;
}
result:
first: Success
next: Illegal seek
why? any resonable explanation? i found no information about this in man pages.
thanks in advance (2 Replies)
I have following problem with this code..
First time trough the main loop.....
perror gives ....blocked signal:success(all other times gives illlegal seek)
Should every time trought the main loop be success??
And the perror otside of main loop...didn't change mask:success
That line of code... (2 Replies)
i am trying to use the perror function:
something like
perror("WRONG!!!");
but when i see the message in the terminal, it comes out like
WRONG!!! : Success
How can i change it to
WRONG!!! : WRONG!!!
well i just want to have my own custom message for the part after the colon... (1 Reply)