Created
February 24, 2026 06:14
-
-
Save bg1bgst333/c142d758b5116214120f56dbb93b6650 to your computer and use it in GitHub Desktop.
fopen#return_value#NULL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* ヘッダファイルのインクルード */ | |
| #include <stdio.h> /* 標準入出力 */ | |
| /* main関数の定義 */ | |
| int main(void){ | |
| /* ポインタの宣言 */ | |
| FILE *fp; | |
| /* ファイルを開く. */ | |
| fp = fopen("test.txt", "r"); | |
| if (fp == NULL){ /* NULLなら失敗. */ | |
| /* perrorでエラー内容を出力. */ | |
| perror("fopen"); | |
| return 1; | |
| } | |
| /* ファイルを閉じる. */ | |
| fclose(fp); | |
| /* プログラムの終了 */ | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment