🦄 refactor(C13, C14, C115): 更新了linux系统开发部分的结构
This commit is contained in:
31
C13-IO/stdio/fopen.c
Normal file
31
C13-IO/stdio/fopen.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen("tmp", "r");
|
||||
if (NULL == fp)
|
||||
{
|
||||
// fprintf(stderr, "fopen() failed! errno = %d\n", errno);
|
||||
// out: fopen() failed! errno = 2
|
||||
/* errno:定义路径 /usr/include/asm-generic/errno-base.h */
|
||||
|
||||
// perror("fopen()");
|
||||
// out: fopen(): No such file or directory
|
||||
|
||||
fprintf(stderr, "fopen(): %s\n", strerror(errno));
|
||||
// out: fopen(): No such file or directory
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
puts("OK!");
|
||||
|
||||
fclose(fp);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user