fun-file.c

来自「linux下的C语言开发」· C语言 代码 · 共 28 行

C
28
字号
/*-*//******************************************************** * Question:						* *	The following program can't open the file no	* *	matter what name we give it. Why?		* ********************************************************//*+*/#include <stdio.h>#include <stdlib.h>	int main(){    char            name[100];  /* name of the file to use  */    FILE           *in_file;    /* file for input */    printf("Name? ");    fgets(name, sizeof(name), stdin);    in_file = fopen(name, "r");    if (in_file == NULL) {        fprintf(stderr, "Could not open file\n");        exit(8);    }    printf("File found\n");    fclose(in_file);    return (0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?