編譯c語言錯誤代碼,c語言代碼常見的錯誤

本文目錄一覽:

C語言編譯報錯

#include stdio.h

#include string.h

int main()

{

int gg(int i);

int i;

while(1){

i=0;

printf(” 1.查看歷史日程表\n”);

printf(” 2.輸入新的日程表\n”);

printf(” 3.查看已完成的日程表\n”);

printf(” 4.查看未完成的日程表\n”);

printf(” 5.退出登錄\n”);

printf(” 請選擇相應序號: “);

scanf(“%d”,i);

if(i==5){

break;

}

gg(i);

printf(“\n”);

printf(“\n”);

printf(“\n”);

}

}

int gg(int i){

int aa();

int bb();

int cc();

int dd();

switch(i){

case 1:

aa();break;

case 2:

bb();break;

case 3:

cc();break;

case 4:

dd();break;

}

}

int aa(){

FILE*fp;

int length=1000;

char str[1001];

if((fp=fopen(“11s.txt”,”r”))==NULL){

printf(“無文件”);

return 0;

}

while(fgets(str,length,fp)!=NULL){

printf(“%s”,str);}

return 1;

fclose(fp);

}

int bb(){

FILE*fp;

char str[400];

printf(“內容如下:\n”);

scanf(“%s”,str);

if((fp=fopen(“11s.txt”,”a+”))==NULL){

printf(“文件不存在”);

return 0;

}

fputs(“\n”,fp);

fputs(str,fp);

printf(“加入成功”);

fclose(fp);

return 1;

}

int cc(){

FILE*fp;

int length=1000;

char str[1001];

printf(“內容如下:\n”);

if((fp=fopen(“11s.txt”,”r”))==NULL){

printf(“無文件”);

return 0;

}

while(fgets(str,length,fp)!=NULL){

if(strstr(str,”已完成”)!=NULL){

printf(“%s”,str);

}

}

fclose(fp);

return 1;

}

int dd(){

FILE*fp;

int lenght=1000;

char str[1001];

printf(“內容如下:\n”);

if((fp=fopen(“11s.txt”,”r”))==NULL){

printf(“無文件”);

return 0;

}

while(fgets(str,lenght,fp)!=NULL){

if(strstr(str,”未完成”)!=NULL){

printf(“%s”,str);

}

}

fclose(fp);

return 1;

}

c語言,這個程序編譯過不了,錯誤代碼c4996,錯在哪裡,這個是打開一個文件的程序

錯誤代碼之後是錯誤原因,下面還會告訴你錯誤發生在哪一行第幾個字元

C4996是因為使用了不安全的函數,例如scanf、gets等。VS中要求用MS自創的_s系列函數替代這些原始庫函數,如用scanf_s替代scanf,以防止緩衝區溢出。

C語言錯誤C2143,具體代碼如下,如何修改?

matlab中如果編寫代碼錯誤,怎麼修改 1、首先需要打開文件,修改代碼格式命令如下cd(需要設定為工作路徑的地址),敲擊回車就會生效。2、或者在命令行窗口中輸入pathtool,敲擊回車,接著會彈出設置路徑的窗口。3、最後,設置成功,如圖所示,再次在命令行窗口中輸入cd就可以校驗是否修改成功,這樣操作即可。

c語言 編譯錯誤

看紅線指向的strings[seek]是一個char,而strcmp函數是連接字元串的,函數傳參錯誤

關於C語言在編譯時常出現的錯誤有哪些?

1、fatal error C1010: unexpected end of file while looking for precompiled header directive。

尋找預編譯頭文件路徑時遇到了不該遇到的文件尾。(一般是沒有#include “stdafx.h”)

2、fatal error C1083: Cannot open include file: ‘R…….h’: No such file or directory

不能打開包含文件「R…….h」:沒有這樣的文件或目錄。

3、error C2011: ‘C……’: ‘class’ type redefinition

類「C……」重定義。

4、error C2018: unknown character ‘0xa3’

不認識的字元’0xa3’。(一般是漢字或中文標點符號)

5、error C2057: expected constant expression

希望是常量表達式。(一般出現在switch語句的case分支中)

6、error C2065: ‘IDD_MYDIALOG’ : undeclared identifier

「IDD_MYDIALOG」:未聲明過的標識符。

7、error C2082: redefinition of formal parameter ‘bReset’

函數參數「bReset」在函數體中重定義。

8、error C2143: syntax error: missing ‘:’ before ‘{‘

句法錯誤:「{」前缺少「;」。

9、error C2146: syntax error : missing ‘;’ before identifier ‘dc’

句法錯誤:在「dc」前丟了「;」。

10、error C2196: case value ’69’ already used

值69已經用過。(一般出現在switch語句的case分支中)

11、error C2509: ‘OnTimer’ : member function not declared in ‘CHelloView’

成員函數「OnTimer」沒有在「CHelloView」中聲明。

12、error C2511: ‘reset’: overloaded member function ‘void (int)’ not found in ‘B’

重載的函數「void reset(int)」在類「B」中找不到。

13、error C2555: ‘B::f1’: overriding virtual function differs from ‘A::f1’ only by return type or calling convention

類B對類A中同名函數f1的重載僅根據返回值或調用約定上的區別。

14、error C2660: ‘SetTimer’ : function does not take 2 parameters

「SetTimer」函數不傳遞2個參數。

15、warning C4035: ‘f……’: no return value

「f……」的return語句沒有返回值。

16、warning C4553: ‘= =’ : operator has no effect; did you intend ‘=’?

沒有效果的運算符「= =」;是否改為「=」?

17、warning C4700: local variable ‘bReset’ used without having been initialized

局部變數「bReset」沒有初始化就使用。

18、error C4716: ‘CMyApp::InitInstance’ : must return a value

「CMyApp::InitInstance」函數必須返回一個值。

19、LINK : fatal error LNK1168: cannot open Debug/P1.exe for writing

連接錯誤:不能打開P1.exe文件,以改寫內容。(一般是P1.Exe還在運行,未關閉)

20、error LNK2001: unresolved external symbol “public: virtual _ _thiscall C……::~C……(void)”

連接時發現沒有實現的外部符號(變數、函數等)。

function call missing argument list 調用函數的時候沒有給參數。

member function definition looks like a ctor, but name does not match enclosing class 成員函數聲明了但沒有使用

unexpected end of file while looking for precompiled header directive 在尋找預編譯頭文件時文件意外結束,編譯不正常終止可能造成這種情況

原創文章,作者:IFNB,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/145207.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
IFNB的頭像IFNB
上一篇 2024-10-26 11:56
下一篇 2024-10-27 23:47

相關推薦

發表回復

登錄後才能評論