Help us and donate little Bitcoins to pay the server costs: 1AXLPuRUBYc1JczTW4XS65GL6oWjNP2Vt2

User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer







because of the inhumane working conditions at amazon in Germany, I will offer the Amazon app no more! (ARD Reportage)
c:stdio.h:perror

perror

    void perror(const char *str);

Prints str (if non-null) and strerror(errno) to standard error as would:

fprintf(stderr, "%s: %s\n", (s != NULL ? s : ""), strerror(errno))

C Sourcecode Example

/* 
 * perror example code
 * http://code-reference.com/c/stdio.h/perror 
 */
 
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
 
int main ( void )
{
FILE *stream;
 
stream = fopen("test_not_exists.txt","r");
 
if (stream == 0) {
perror("Here comes the perror code ->");
return 1;
}
 
printf("its all fine\n");
 
fclose (stream);
return 0;
 
}

output

 ./perror 
  Here comes the perror code ->: No such file or directory
advertising
c/stdio.h/perror.txt · Last modified: 2013/01/22 22:02 (external edit)

The new Question & Answer System is online and waiting for your Questions about Programming problems http://ask.code-reference.com Impressum