The perror function prints the error message.

Source: Internet
Author: User

Perror prints system error messages

Void perror (const char * s );

Prototype in stdio. h

Note:

Perror prints the error message to the stderr stream (via the console), indicating the system error information of the last library program.

First
Print the string parameter, and then
Is a colon, and then
Is the information corresponding to the current errno value, and the last line feed
. Specify that the transmitted file name is a string parameter.

Use the global variable sys_errlist (defined in stdio. H, extern char * _ cdecl sys_errlist [];)

Array of characters for obtaining information, errno (
Defined in stdio. H,
Extern int _ cdecl errno;) can be used as the subscript of the array to find the string corresponding to the error code. The string itself does not include a line break.

Global variable sys_nerr
(Defined in stdio. H,
Extern int _ cdecl sys_nerr;) contains the number of items in the array

Perror does not return values.

Applicable to Unix systems, defined in ANSI C

# Include <stdio. h>
Int main ()
{
File * FP;
Fp = fopen ("perror. dat", "R ");
If (! FP)
Perror ("unable to open the file ");
Return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.