前提・実現したいこと
ここに質問の内容を詳しく書いてください。
(例)c language でファイル入出力のコードです
発生している問題・エラーメッセージ
エラーメッセージ
重大度レベル コード 説明 プロジェクト ファイル 行 抑制状態
エラー C4996 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ConsoleApplication1 C:\Users******\source\repos\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp 14
該当のソースコード
c languageここに言語名を入力
ソースコード
#include <iostream> #include <stdio.h> #include<string.h> #define _CRT_SECURE_NO_WARNINGS #include<algorithm> _CRT_SECURE_NO_WARNINGS int main() { FILE* fp; fp = fopen("test.txt", "w"); if (fp == NULL) { perror("defaulted to open the file\n"); return -1; } else { printf("successed to open the file\n"); } fprintf(fp, "first time to ocfile\n"); if (fclose(fp) != 0) { perror("defaulted to close the file\n"); return -1; } else { printf("closed the file\n"); } return 0; };
試したこと
_CRT_SECURE_NO_WARNINGSをつかった
補足情報(FW/ツールのバージョンなど)
visual studio 2019。
こちらの質問が複数のユーザーから「過去の低評価」という指摘を受けました。

回答3件
あなたの回答
tips
プレビュー