1. 程式人生 > >錯誤處理error C4996: 'fopen': This function or variable may be unsaf

錯誤處理error C4996: 'fopen': This function or variable may be unsaf

編譯出錯資訊:錯誤    1    error 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.  

首先我們分析錯誤提示,這個方法或者變數可能是不安全的,考慮使用fopen_s來代替。若要禁用安全警告,看線上幫助的具體細節。

方法1:我們用fopen_s來代替原來的方法fopen

方法2:在c++前處理器中新增_CRT_SECURE_NO_WARNINGS的定義。

第二種方法我們可以這麼做:

(1)點選專案--》屬性--》c/c++--》前處理器--》預處理定義--》點選下拉按鈕


(2)新增_CRT_SECURE_NO_WARNINGS,點選確定就ok了。


相關推薦

錯誤處理error C4996: 'fopen': This function or variable may be unsaf

編譯出錯資訊:錯誤    1    error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, u

錯誤處理error C4996: 'fopen': This function or variable may be unsafe

編譯出錯資訊:錯誤    1    error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation,

Visual Studio 2013 編譯錯誤error C4996: 'sprintf': This function or variable may be unsafe. 】的解決方案

在VS 2013 中編譯 C++ 語言專案,如果使用了 sprintf函式,編譯時便會提示如下錯誤: 錯誤    5    error C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s i

VS2013使用scanf、gets及字串函式編譯報錯error C4996: 'scanf': This function or variable may be unsafe. 原因及解決方案

VS2013使用scanf、gets及字串函式編譯報錯error C4996: ‘scanf’: This function or variable may be unsafe. 原因及解決方案 問題原因: C語言的標準函式中,一些讀取或寫入記憶體的函式存在記憶

vs的【warning C4996:'fopen': This function or variable may be unsafe】解決方案

二、編譯警告:warning C4996 與 Security Enhancements in the CRT 將過去的工程用VS2005開啟的時候。你有可能會遇到一大堆的警告:warning C4996。 比如:warning C4996: 'strcpy': This function or varia

VS2015:error C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead

使用VS2015學習比較傳統的C語言或者做演算法題目的時候經常會使用到scanf但是,這個函式有點玩具函式的意味,並不安全。所以目前的開發中已經非常不建議使用,至於原因,就像這位大哥說的:新版vc庫新增的警告 讓我們欣賞完這個錯誤的全部內容: error

error C4996: 'scanf': This function or variable may be unsafe.Visual Studio系列編譯器使用scanf函式報錯

在使用Visual Studio 系列編譯器使用scanf函式是,是否需到下面這句話呢?error C4996: ‘scanf’: This function or variable may be unsafe. Consider using scanf_s i

error C4996: 'sprintf': This function or variable may be unsafe.Consider using sprintf_s instead.

直接使用微軟推薦的修改後的函式sprintf_s, 其他類似的函式報錯也同樣 亦可以 選項Project   |   Configuration   Properties   |   C/C++   |   Preprocessor   |   Preprocesso

【問題】warning C4996: 'scanf': This function or variable may be unsafe

問題 經常有初學者在學習C/C++語言的時候,使用VS系列編譯器。 在使用scanf函式從標準輸入讀取字元、數字的時候,看到編譯器報一個警告: warning C4996: 'scanf': This function or variable may be

vs2013/2015中scanf函數類似於error C4996: 'scanf': This function or variable may be unsafe的安全檢查錯誤

span 調試 ria 安全性 init 點擊 scan online pan   在使用vs2015時,遇到了scnaf函數安全性的問題,程序不能正常運行,錯誤如下: error C4996: ‘scanf‘: This function or variable may

Visual Studio 2013 編譯錯誤error C4996: 'scanf': This function or variable may be unsafe. 】

使用vs2013的scanf函式時出現錯誤,在網上找到的解決方法,轉載過來,我使用的方法二 error C4996: ‘scanf’: This function or variable may be unsafe. Consider using scanf_s instead. To

VS2017出現C4996 'fopen': This function or variable may be unsafe. Consider using fopen_s instead.錯誤

VS2017利用fopen和fscanf讀取檔案時出現以下錯誤資訊: C4996 ‘fopen’: This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation,

c++ 去除 warning C4996 This function or variable may be unsafe.

原因是高版本的vs使用了更加安全的run-time library routines。 新的Security CRT functions(就是那些帶有“_s”字尾的函式) 出現這樣的警告,是因為VC2005之後的版本中認為CRT中的一組函式如果使用不當,可能會產生諸如記憶體洩露,緩衝區溢位,非法

《VS如何解決warning C4996: 'vsprintf': This function or variable may be unsafe.問題》

問題描述  使用VS2010在生成解決方案的時候,輸出視窗會出現一大堆warning C4996: 'xxx': This function or variable may be unsafe.這樣的警告資訊。參考了另外一位博主的說法:這是微軟的警告,主要是因為那些C庫的函

解決This function or variable may be unsafe

idt 技術 erro 預處理 管理 復雜 屬性 safe nbsp 當使用VS編寫C/C++時,經常會遇到的一個錯誤是:   error C4996: ‘*****‘: This function or variable may be unsafe.   哎?可我明明使用

VS2013執行C++報錯:This function or variable may be unsafe. Consider using fopen_s instead.

在vs2013中執行時發生的關於方法呼叫的不安全錯誤。 1.更換方法,但是有些方法更改後引數不變,所以可能比較麻煩。 2.新增一條前處理器定義: 點選專案——>屬性——>c/c++——>前處理器——>預處理定義——>點選下拉按鈕——>編輯——>新增“_CRT_S

"無法解析的外部符號" 和 "This function or variable may be unsafe"

1、問題一: 無法解析的外部符號 》》》 , 一般是沒有新增庫檔案(lib)或者標頭檔案; 2、This function or variable may be unsafe 。 (1)用VS2013打開出現錯誤的程式碼檔案 (2)在工程檔名處右擊滑鼠開啟快捷選單,

C++程式設計:用二分法求方程解(以及解決VS 2017中'scanf':this function or variable may be unsafe.`問題)

前言 本文旨在用C++解決問題:“用二分法求方程的解。”以及解決VS 2017 中報錯問題:C4996 'scanf':this function or variable may be unsafe. 一、題目描述 給出等式8x4+7x3+2x2+3x+6

OpenGL報錯:fopen:this function or variable maybe unsafe

VS2015+OpenGL+win10 64bit 編譯報錯:error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable d

mysql 匯入sql檔案,出現ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL報錯

ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL mysql的設定預設是不允許建立函式 1、更改全域性配置       SET GLOBAL l