C语言常见错误分析汇总
C语言常见错误分析汇总 1、 在一个工程里出现两个main函数时 3.obj : error LNK2005: _main already defined in file1.obj Debug/HELLO.exe : fatal error LNK1169: one or more multiply defined symbols found 这个就是说,你的main函数重定义了。你看看是不是你的工程里面,包含了很多个有main函数的文件? 2、 fatal error C1010: unexpected end of file while looking for precompiled header directive 出现这个错误的原因是,工程类型建错了,应该选择win 32 console application 3、拼写错误 (1)#include //头文件拼写错了 void main() { printf("doeifweofupwp"); } fatal error C1083: Cannot open include file: 'stido.h': No such file or directory (2)#inculde //include拼写错了 void main() { printf("doeifweofupwp"); } fatal error C1021: invalid preprocessor command 'inculde'(无效的预编译命令inculde) (3)#include void mian() //main拼写错了 { printf("doeifweofupwp"); }
C语言中常见的错误
."c"not an argument in function sum该标识符不是函数的参数 2.array bounds missing]in function main缺少数组界限符"]" 3.Array size too large in function main数组规模太大 4.bad file name format in include directive在包含指令中的文件名格式不正确. 5.Call of non-function in function main调用未经过定义的函数. 6.cannot modify a const object in function main对常量不能进行修改. 7.character constant too long in function main字符常量太大 8.constant expression required in funtion main数组定义的时候,数组大小要求是常数 https://www.360docs.net/doc/968732027.html,pound statment missing}in function main复合语句漏掉符号"{" 10.declaration syntax error in function main宣告语法错误 11.expression syntax in function main表达式语法错误 12.extra parameter in call to sum in function调用函数时使用了过多的参数 13.illegal use of floating point in function main浮点数的不合法使用 14.illegal pionter subtraction in function main不合法的指针相减 15.invalid pointer addition in function main无效的指针相加 16.out of memory in function main内存不足
C语言程序改错2
1、以下程序的功能是求如下表达式: 1 1 1 S = 1 + ——+ ———+ ...... + ——————— 1+2 1+2+3 1+2+3+......+n 『答案』:1 scanf("%d",&n); 2 float fun(int n) 3 for(i=1;i<=n;i++) 4 s+=1.0/t 或s= s + 1.0 /t; 2、题目:函数fun的功能是:根据整型形参m的值,计算如下公式的值。 1 1 1 t = 1- ——- ——- ... - —— 2x2 3x3 mxm 例如,若m=5,则应输出:0.536389 『答案』:1 for(i=2;i<=m;i++)或for(i=2;i 2 float s=0,t=1,p=1; 3 while(fabs(t)>1e-4)或while(fabs(t)>0.0001) 4 printf("pi=%f\n", s * 4 ); 4、功能:计算正整数num的各位上的数字之积。例如,输入252,则输出应该是20。『答案』:1 long k=1; 或long int k=1; 2 num/=10; 或num=num/10; 3 scanf("%ld",&n); 4 printf("\n%ld\n",fun(n)); 5、功能:(与上题略有不同)计算正整数num的各位数字之积。例如,若输入:252,则输出应该是:20。若输入:202,则输出应该是:0。 『答案』:1 {long k=1; 2 num/=10; 或num=num/10; 3 } while(num) ; 或}while(num!=0); 或}while(num>0); 6、题目:判断m是否为素数,若是返回1,否则返回0。 『答案』:1 int fun( int m) 或fun( int m) 2 for(i=2;isqrt(i)) 4 return i; 或return (i);
C语言调试时出现的错误及调整方法
VC中LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16错误2009-10-09 11:11 学习VC++时经常会遇到链接错误LNK2001,而一般说来发生连接错误时,编译都已通过。产生连接错误的原因非常多,尤其LNK2001错误,常常使人不明其所以然。产生 LNK2001错误的原因:一个是由于编码错误导致的LNK2001,在这不想详细说.另一个由于编译和链接的设置而造成的LNK2001.最经常发生的是:"LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol",产生这个错误的原因是没有为wWinMainCRTStartup设定程序入口. 认识这个错误首先在新建工程时要分清Win32 Application和Win32 Console Application.它们都是工作在32位Windows环境的程序.其中Win32 Application 就是普通的常见的窗口应用程序,当然有的界面做得比较 个性化,比如圆形的、不规则形状的.它们都是所谓的GUI(Graphics User Interface图形用户接口),我们可以通过鼠标点击来完成控制。而Win32 Console Application (win32控制台应用程序)往往是像MS-DOS窗口(XP中叫命令提示符)的样子出现,我们得用键盘输入各种命令来使用它,或者叫CUI(Character User Interface字符用户接 口)。 遇到如下链接错误: Linking... /subsystem:windows LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 Debug/TestWin.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. 解决方法是:将project-settings-link的project options里的/subsystem:windows 改成/subsystem:console 因为Win32 Application的入口函数为WinMain Win32 Console Application的入口函数是main 也就是说,如果你编写传统的C程序,必须建立Win32 Console程序,但VC里面默认的是Win32 Application,于是上面提及的链接错误就就经常出现了 而Win32 Application和Win32 Console的区别就在于VC里链接参数不同 另外几种error LNK2001错误: 在创建MFC项目时, 不使用MFC AppWizard向导, 如果没有设置好项目参数, 就会在编译时产生很多连接错误, 如error LNK2001错误, 典型的错误提示有: libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16 nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex 下面介绍解决的方法: 1. Windows子系统设置错误, 提示: libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
C语言调试常见错误及修改方法(附习题)
1.调试 C 程序时常见的错误类型分析 一般情况下,错误主要分为两大类:一、语法错误。对于这种错误,用编译器很容易解决。所以,改错题的第一步是先编译,解决这类语法错误。下面总结了二级C 语言上机改错题中常见的语法错误: (1) 丢失分号,或分号误写成逗号。 (2) 关键字拼写错误,如本来小写变成大写。 (3) 语句格式错误,例如for 语句中多写或者少写分号。 (4) 表达式声明错误,例如:少了() (5) 函数类型说明错误。与main ()函数中不一致。 (6) 函数形参类型声明错误。例如:少* 等。 (7) 运算符书写错误,例如:/ 写成了。二、逻辑错误,或者叫语义错误,这和实现程序功能紧密相关,一般不能用编译器发现。对于逻辑错误可以按这样的步骤进行查找。 (1) 先读试题,看清题目的功能要求。 (2) 通读程序,看懂程序中算法的实现方法。 (3) 细看程序,发现常见错误点。 2.改错题的改错方式总结,当然这些总结只能对大部分改错行有效 1、若错误行是函数首部,可分为以下几种情况: A、该行最后若有分号则删除,中间若有分号则改成逗号 B、形参类型不一致的问题,特别是指针类型,若后面用到某形参时有指针运算则该形参必为指针类型;若形参是二维数组或指向m 个元素的指针变量,则第二维的长度必须与main 中对应数组的第二维长度相同 C、函数类型不一致的问题,若函数中没有return语句则函数类型为void,若有return语句则函数的类型必须与return 后变量的类型一致。 2、若错误行是if 或while 语句,则首先看有没有用小括号将整个表达式括起,若没有则加上小括号。 3、若错误行中有if、while 、for 则要特别注意条件表达式的错误问题: A、指针变量的应用,若表达式中有指针变量且没有指针运算符,则加上指针运算符 B、若条件表达式中只有一个等于号,则改成两个等于号,若为其它比较运算符则一般是进行逆转或加一个等于号 C、f or 中要用分号分隔表达式,而不是用逗号 4、语法错误 A、语句缺少分号,若错误行中有语句没有用分号结束,则加上分号。 B、大小写不对,若错误行中有大写字母则一般都改成小写字母。 5、指针变量的运用,若错误行中有指针变量,并且该变量名前没有指针运算符则一般都是加上指针运算符 6、若错误行为return 语句,则首先看是否是缺少分号若是则加上分号即可;否则就是return 后的变量或表达式错误(此时可通过看题意,来分析该返回哪一变量或表达式)
C语言常见错误提示信息的英汉对照
常见错误提示信息的英汉对照Ambiguous operators need parentheses : 不明确的运算需要用括号括起Ambiguous symbol ’xxx’ : 不明确的符号 Argument list syntax error : 参数表语法错误 Array bounds missing : 丢失数组界限符 Array size toolarge : 数组尺寸太大 Bad character in paramenters :参数中有不适当的字符 Bad file name format in include directive :包含命令中文件名格式不正确Bad ifdef directive synatax :编译预处理ifdef有语法错 Bad undef directive syntax :编译预处理undef有语法错 Bit field too large :位字段太长 Call of non-function :调用未定义的函数 Call to function with no prototype :调用函数时没有函数的说明 Cannot modify a const object :不允许修改常量对象 Case outside of switch: 漏掉了case 语句 Case syntax error :Case 语法错误 Code has no effect 代码不可述不可能执行到 Compound statement missing{ 分程序漏掉"{" Conflicting type modifiers 不明确的类型说明符 Constant expression required 要求常量表达式 Constant out of range in comparison 在比较中常量超出范围 Conversion may lose significant digits 转换时会丢失意义的数字Conversion of near pointer not allowed 不允许转换近指针 Could not find file ’xxx’ 找不到XXX文件 Declaration missing ; 说明缺少";" Declaration syntax error 说明中出现语法错误 Default outside of switch Default 出现在switch语句之外 Define directive needs an identifier 定义编译预处理需要标识符 Division by zero 用零作除数 Do statement must have while Do-while语句中缺少while部分 Enum syntax error 枚举类型语法错误 Enumeration constant syntax error 枚举常数语法错误 Error directive :xxx 错误的编译预处理命令 Error writing output file 写输出文件错误 Expression syntax error 表达式语法错误 Extra parameter in call 调用时出现多余错误 File name too long 文件名太长Function call missing ) 函数调用缺少右括号Fuction definition out of place 函数定义位置错误 Fuction should return a value 函数必需返回一个值 Goto statement missing label Goto语句没有标号 Hexadecimal or octal constant too large 16进制或8进制常数太大 Illegal character ’x’ 非法字符x Illegal initialization 非法的初始化
C语言常见错误提示
C语言常见错误提示 Ambiguous operators need parentheses 不明确的运算需要括号Ambiguous symbol ''xxx'' 不明确的符号 Argument list syntax error 参数表语法错误 Array bounds missing 丢失数组界限符 Array size too large 数组尺寸太大 Bad character in parameters 参数中有不适当的字符 Bad file name format in include directive包含命令中文件名格式不正确 Call of non-function 调用未定义的函数 Call to function with no prototype 调用函数时没有函数说明Cannot modify a const object 不允许修改常量对象 Case outside of switch 漏掉了case 语句 Case syntax error Case 语法错误 Code has no effect 代码不可述(不可能执行到) Compound statement missing{ 分程序漏掉"{" Conflicting type modifiers 不明确的类型说明符 Constant expression required 要求常量表达式 Constant out of range in comparison 在比较中常量超出范围Conversion may lose significant digits转换时会丢失意义的数Could not find file ''xxx'' 找不到XXX文件 Declaration missing ; 说明缺少";" Declaration syntax error 说明中出现语法错误 Default outside of switch Default出现在switch语句之外Define directive needs an identifier define命令需要标识符Division by zero 用零作除数 Do statement must have while Do语句中需要while部分Enum syntax error 枚举类型语法错误 Enumeration constant syntax error 枚举常数语法错误Error directive: xxx 错误的编译预处理命令xxx Error writing output file 写输出文件错误 Expression syntax error 表达式语法错误 Extra parameter in call 调用时出现多余参数 File name too long 文件名太长 Function call missing ) 函数调用缺少右括号 Function definition out of place 函数定义位置错误Function should return a value 函数必需返回一个值Hexadecimal or octal constant too large 16进制或8进制常数太大Illegal character ''x'' 非法字符x Illegal initialization 非法的初始化 Illegal octal digit 非法的8进制数 Illegal pointer subtraction 非法的指针相减 Illegal structure operation 非法的结构体操作 Illegal use of floating point 非法的浮点运算 Illegal use of pointer 指针使用非法 Improper use of a typedef symbol 类型定义符号使用不恰当In-line assembly not allowed 不允许使用行间汇编Incompatible storage class 存储类别不相容 Incompatible type conversion 不相容的类型转换 Incorrect number format 错误的数据格式 Incorrect use of default default使用不当 Invalid indirection 无效的间接运算 Invalid pointer addition 指针相加无效 Irreducible expression tree 无法执行的表达式运算 Lvalue required 需要左值 Macro argument syntax error 宏参数语法错误 Macro expansion too long 宏的扩展以后太长Mismatched number of parameters in definition定义中参数个数不匹配 Misplaced break 此处不应出现break语句 Misplaced continue 此处不应出现continue语句Misplaced decimal point 此处不应出现小数点 Misplaced else 此处不应出现else Must be addressable 必须是可以编址的 Must take address of memory location 必须存储定位的地址No declaration for function ''xxx'' 没有函数xxx的说明 No stack 缺少堆栈 No type information 没有类型信息 Non-portable pointer assignment 不可移动的指针赋值 Non-portable pointer comparison 不可移动的指针比较Non-portable pointer conversion 不可移动的指针转换 Not a valid expression format type 不合法的表达式格式Not an allowed type 不允许使用的类型 Numeric constant too large 数值常太大 Out of memory 内存不够用 Parameter ''xxx'' is never used 能数xxx没有用到 Pointer required on left side of -> 符号->的左边必须是指针
C语言程序改错题
第12次上机程序改错第1题 【程序改错】 -------------------------------------------------------- 功能:求二分之一的圆面积,函数通过形参得到圆的半径,函数返回二分之一的圆面积。 例如:输入圆的半径值:19.527 输出为:s = 598.950017。 ------------------------------------------------------*/ #include #include /**********FOUND**********/ double fun( r) double fun(double r) { double s; /**********FOUND**********/ s=1/2*3.14159* r * r; s=1.0/2*3.14159*r*r; /**********FOUND**********/ return r; return s; } main() { float x;
printf ( "Enter x: "); scanf ( "%f", &x ); printf (" s = %f\n ", fun ( x ) ); } 第2题【程序改错】 功能:先将在字符串s中的字符按逆序存放到t串中,然后把s中的字符按正序连接到t串的后面。 例如:当s中的字符串为:“ABCDE”时,则t中的字符串应为:“EDCBAABCDE”。 ------------------------------------------------------*/ #include #include #include void fun (char *s, char *t) { /**********FOUND**********/ int i; int sl,i; sl = strlen(s); for (i=0; ic语言错误调试大全
A Ambiguous operators need parentheses 不明确的运算需要用括号括起。二义性操作符需要括号,但两个移位、关系或按位操作符在一起使用而不加括号时,发现此警告;但一个加法或减法操作符不加括号而与一个移位操作符出现在一起时,也发出此警告。 Ambiguous symbol ''xxx'' 不明确的符号,二义性符号…xxxxxxxx?。两个或多个结构的某一域名相同,但具有的偏移、类型不同。在变量或表达式中引用该域而未带结构名时,将产生二义性,此时需修改某个域名或在引用时加上结构名。 Argument list syntax error 参数表语法错误参数表出现语法错误。函数调用时,参数与参数之间必须以逗号隔开,并以一右括号结束。若源文件中含有一个其后不是逗号也不是右括号的参数,则出错。 Argument #missing name 参数#名丢失。参数名已脱离用于定义函数的函数原型,如果函数以原型定义,该函数必须包括所有的参数名。 Array bounds missing 丢失数组界限符数组的界限符…]?丢失。原因是在源文件中定义了一个数组,但此数组没有以一右方括号结束。, Array size toolarge 数组尺寸太大,数组长度太长。定义的数组太大,而可用内存不够。Assembler startement too long 汇编语句太长。内部汇编语句最长不能超过480个字节。 B Bad call of in line function 内部函数非法调用 在使用一个宏定义的内部函数时,没有正确调用。一个内部函数以下划双线(_)开始和结束。 Bad character in paramenters 参数中有不适当的字符 Bad configuration file 配置文件不正确。Turboc.cfg配置文件中包含不是合适命令行选择项非注解文字。 配置文件命令选择项必须以一短横线开始。 Bad file name format in include directive 包含命令中文件名格式不正确使用include指令时,文件名格式不正确。include 文件名必须用引号或尖括号括起来。例如:include "stdio.h"或include ,否则将
分析C语言编程中常见错误及解决办法
龙源期刊网 https://www.360docs.net/doc/968732027.html, 分析C语言编程中常见错误及解决办法 作者:胡金荣 来源:《数码设计》2018年第03期 摘要:C语言是计算机基础教学中被广泛利用的一种教学语言,是目前计算机技术应用的重要内容,利用C语言程序的编写可以为办公自动化提供更为便捷的条件,因此强调其在具体实践中的利用现实意义显著。在学习应用C语言编程发现其在实践中存在着一些比较常见的错误,这些错误对办公质量和效率有重要的影响,所以要对其进行有效的解决。本文就C语言编程中常见的错误和解决方法做具体分析,旨在指导实践工作,提升编程的效率和质量。 关键词:C语言编程;常见错误;解决办法 中图分类号:TP312.1 文献标识码:A 文章编号:1672-9129(2018)03-0021-02 Analyze Common Mistakes in C Language Programming and Solutions HU Jinrong* (Xinjiang Shihezi Engineering Technology School, Xinjiang Shihezi, 832000, China) Abstract:C language is a widely used teaching language in computer basic education. It is an important content of computer technology application. The use of C language program can provide more convenient conditions for office automation. Therefore, it emphasizes its practice. The use of real significance in the. Learning to use the C language programming found that there are some common mistakes in practice, these errors have an important impact on office quality and efficiency, so we must effectively solve it. This article analyzes the common mistakes and solutions in C language programming and aims to guide practical work and improve the efficiency and quality of programming. Keywords:C programming; common mistakes; solutions 引用:胡金荣. 分析C语言编程中常见错误及解决办法[J]. 数码设计, 2018, 7(3): 21-22. Cite:HU Jinrong. Analyze Common Mistakes in C Language Programming and Solutions[J]. Peak Data Science, 2018, 7(3): 21-22. 引言 C语言是计算机基础教学中被广泛利用的一种教学语言,从具体的分析来看,C语言的显著特点是功能比较强、使用方便且灵活,而且对语法的检查不像其他的语言那样严格。这些显