用户名:  密码:   
您当前的位置:首页 > 程序设计 >  C与C++ > 

VC6中遇到的编译错误

上次修改时间: 2017-12-11 11:11:39      来源:网络总结      作者:钢铁长陈
上一页      路径:DSD\Learn\C与C++\小甲鱼C语言\      下一页

1.  2.c(191) : error C2001: newline in constant
 2.c(192) : error C2143: syntax error : missing ')' before '}'
原因:printf("y=%d,x=%d,y,x); 这句少右分号:应改为printf("y=%d,x=%d",y,x);

2. 编译不出错,运行时提示:3.obj : error LNK2001: unresolved external symbol _sqr
 Debug/3.exe : fatal error LNK1120: 1 unresolved externals
原因1:q = sqr(disc)/(2*a); //写错了数据函数,sqr应改为sqrt
原因:area=sqr(s*(s-a)*(s-b)*(s-c)); //这里用到sqr函数在math.h头文件中,没有引入该头文件

3. LINK : fatal error LNK1168: cannot open Debug/3.exe for writing
Error executing link.exe.
 原因:调试后再编译就出这种错误,解决方法是重新打开VC6

4. 提示:e:\baiducloud\dos\4.c(1) : error C2143: syntax error : missing '{' before '<'
e:\baiducloud\dos\4.c(1) : error C2059: syntax error : '<'
 原因:include <stdio.h>前加要#改为#include <stdio.h>

5. 提示:E:\BaiduCloud\dos\4.c(118) : error C2106: '=' : left operand must be l-value
 //表左操作符必须是一个左值,就是赋值符左边必须是可以赋值的,
 原因:else if((score>60||score=60)&&score<70)这里的score=60应改为score==60
  //注:上面是因为=的优先级太低导致的错误,如果是赋值在代码中给(score=60)加括号也能通过
 //左值是指在程序中占用内存空间,可以被修改的量,如各种变量

6. 提示:E:\BaiduCloud\dos\4.c(357) : error C2063: 's' : not a function
 原因:f=p*w*s(1-d/100.0);应改为f=p*w*s*(1-d/100.0),即s后必须加*

7. 提示:E:\BaiduCloud\dos\5.c(123) : error C2143: syntax error : missing ';' before ')'
 原因:for (i=1,i<=100,i++)因改为:for (i=1;i<=100;i++),即for中的每条语句要用分号隔开,而不是逗号

8. 提示:e:\baiducloud\dos\6.c(57) : error C2084: function 'void __cdecl main()' already has a body
 原因:有两个void main,上面还有个主函数void main

9. 提示:E:\BaiduCloud\dos\7.c(333) : warning C4013: 'puchar' undefined; assuming extern returning int
 原因:puchar('\n');改为putchar('\n'); 函数名写错,少了个t

10. 提示:7.1.obj : error LNK2001: unresolved external symbol _A Debug/7.exe : fatal error LNK1120: 1 unresolved externals
 原因:在7.exe中在全局变量int A;装加了static int A,int A本就是全局变量,不能再加static,这样7.1.exe中会找不到变量A

11. 提示:E:\BaiduCloud\dos\8.c(311) : error C2100: illegal indirection
 原因:printf("*a[1][0]: %d\n", *a[1][0]);应改为printf("*a[1][0]: %d\n", &a[1][0]); 要把那个*改为&,因为a[1][0]本来就是值了不用再取值

12. 提示:E:\BaiduCloud\dos\8.c(645) : error C2143: syntax error : missing ')' before 'type'
 原因:double *search(double (*pointer)[4] int n)这里的[4]后少了个分号,应改为double *search(double (*pointer)[4], int n)

13. 提示:E:\BaiduCloud\dos\9.c(140) : error C2059: syntax error : 'type'
 原因:可能是我替换的两个导致调试死机的dll的原因,在替换后在电脑上怎么都编译不过,但在虚拟机上原版的vc6下就没有这两个错误。
 解决方法:将int SQ(int y);改成int sq1(int y); 可能是SQ这个名称不能用,但在原版未替换过的dll的vc6下可以编译

14. 提示E:\BaiduCloud\dos\9.c(212) : warning C4715: 'cmp' : not all control paths return a value
 原因:函数int cmp(char *str1, char *str2)返回值为整形,而函数体中没有return语句

15. 提示:E:\BaiduCloud\dos\9.c(260) : fatal error C1004: unexpected end of file found
 原因:是定义了#if...#else 宏,但没有#endif,所以定义宏时,要有#if...#else...#endif

16. 编译时提示:no compile tool is associated with file extension. 表没有编译工具与文件扩展名相关联
 原因是用VC6新建C++应用工程后,点文件——添加,在添加C++源文件时,只输入了文件名,没有扩展名,因写为testcjia.cpp,不能少了.cpp
 //注:在xp下的vc6添加c++源文件时可以不要扩展名,但win8.1的VC6加源文件时必须输入扩展名。否则提示这个错误。