error strerror 函数 用法

#include <stdio.h>
#include <string.h>
#include <errno.h>

int main (void) {
	FILE* fp = fopen ("none", "r");
	if (! fp) {
		printf ("fopen: %d\n", errno);
		printf ("fopen: %s\n", strerror (errno));
		printf ("fopen: %m\n");
		perror ("fopen");
		return -1;
	}

	fclose (fp);

	return 0;
}

[img]http://dl2.iteye.com/upload/attachment/0100/5674/cb7a9cc4-aef9-3ce1-a926-39744d2a62c0.png[/img]



你可能感兴趣的:(c)