「C言語」fopen()でファイル入出力をするサンプル
書式
FILE *fopen(const char *filename, const char *mode);
サンプルコード
#include <stddef.h>
#include <stdio.h>
int main ()
{
FILE *fp;
fp = fopen("file.txt", "r");
if( fp != NULL )
{
printf("access open file file.txt\n");
fclose(fp);
}
fp = fopen("nofile.txt", "r");
if( fp == NULL )
{
printf("cannot open file nofile.txt\n");
}
return(0);
}