strerror_s, _wcserror_s

From RAD Studio
Jump to: navigation, search

Go Up to string.h Index


Header File

string.h, stdio.h

Category

Memory and String Manipulation Routines

Prototype

errno_t strerror_s(char *__s, rsize_t __maxsize, errno_t __errnum);

errno_t _wcserror_s(wchar_t *__s, rsize_t __maxsize, errno_t __errnum);

Description

Reads the error string of a specific error.

strerror_s lets you get the error string of an error specified by __errnum, mapping it to __s.

__s should not be null because, unlike in the strerror case, a run-time constraint violation occurs.

If the length of the string is smaller than __maxsize, then the string is copied to __s.

Return Value

strerror_s returns zero if the length of the desired string is less than __maxsize, or nonzero otherwise.

Example

#include <stdio.h>
#include <errno.h>
#include <string.h>
int main(void)
{
   unsigned int s1max = 100;
   char message[100];
   strerror_s(message, s1max, 3);
   printf("Error: %s\n", message); //3 is Path not found.
   return 0;
}

Portability

POSIX Win32 ANSI C ANSI C++

+

See Also