当前位置:网站首页>[C compilation] collection of error reporting problems
[C compilation] collection of error reporting problems
2022-08-06 15:19:00 【one reed fly fp】
1、[Note] each undeclared identifier is reported only once for each function it appears in
[注] Each undeclared identifier is reported only once for each function that appears to be(Wrong or overwritten identifier)
如:
printf("f("%s", "%s") = %d\n", p, q, result);
修改:
printf("f(\"%s\", \"%s\") = %d\n", p, q, result);
printf 函数里面 double quotes required \ output without error.
2、[Warning] initialization discards ‘const’ qualifier from pointer target type
[警告] Discarded at initialization Discarded from pointer target type
const限定符
如:
const int a[10] = {
0};
char* p = a; //会出现此Warning
解决办法:
const int a[10] = {
0};
const int* p = a;
3、[Error] variable-sized object may not be initialized
[错误] Variable-length objects are not initialized
如:
int n = 5;
int a[n] = {
1,2,3,4,5};
错因:
for variable length arrays(The length is controlled by a variable), Cannot initialize at the same time as the array is defined,A separate assignment initialization is required after the definition.
修改:
int n = 5;
int a[n];
memset(a, 0, sizeof(a)); //合法初始化,将a的所有元素初始化为0
4、[Error] ld returned 1 exit status
[错误] ldReturns an exit status
可能原因:
- The result of the last run was not closed
5、[Error] stray ‘\241’ in program
可能原因:There are illegal characters in the program,Might have accidentally converted to full-width input.
6、The debugging results are inconsistent with the running results
如:
#include <stdio.h>
#include <string.h>
#define LEN 500 //限制输入的字符串长度
int main(){
char str[LEN+1], differ[LEN+1]; //Here the array is not initialized
int len_str, len_differ;
int i;
scanf("%s", str);
len_str = strlen(str);
strncpy(differ, str, 1);
len_differ = strlen(differ);
//在differsearch one by onestr中的元素
for(i=0; i<len_str; i++){
//没被记录
if( strchr(differ, str[i]) == NULL ){
//A single character is spliced todiffer末尾
differ[strlen(differ)] = str[i];
differ[strlen(differ) + 1] = '\0';
}
}
printf("%d", strlen(differ));
return 0;
}
错误原因:暂且未知
解决办法:把数组初始化
7、Cannot enter while debugging
问题描述:
A dialog box pops up after clicking debug,But the dialog is minimized immediately,且无法输入.
原因:
断点设置在 scanf 那一行.
解决办法:
修改断点,Set a breakpoint after the input function.
8、[Error] assignment to expression with array type
错误原因:
- 数组不能直接给数组赋值.
解决办法:
- 若是字符串,可使用
strcpy函数 - 若是数组,You need to assign values one by one.
边栏推荐
- Tencent Cloud Hu Qiming: Analysis and Optimization of Kubernetes Cloud Resources
- js array to remove the specified element [function encapsulation] (including object array to remove the specified element)
- LeetCode: 205. Isomorphic Strings - Simple
- [2022CISCN]初赛 复现
- LODOP.ADD_PRINT_TEXT 参数解释说明
- SQL执行一次完成新增或者修改操作-2022新项目
- Flutter For Web实践
- LeetCode: 392. Judgment Subsequence —— Simple
- LeetCode Brushing Diary: Full Arrangement
- 中国制造实力强横的又一证明,500强的中国企业数量最多
猜你喜欢
随机推荐
内网穿透工具 frp 使用教程
paper speed reading column index
LeetCode 1408. 数组中的字符串匹配
学会make/makefile基本用法
口碑极佳的7个公众号!
数值去0操作
Why do LiveVideoStack courses?
SQL执行一次完成新增或者修改操作-2022新项目
Detailed explanation of car audio service
stc8a--al422B————01, RE has been grounded on the hardware.
【C编译】报错问题收集
js array to remove the specified element [function encapsulation] (including object array to remove the specified element)
Intel transformation was not successful and into loss, AMD grow again and get substantial profits
The real question of the ladder game - 7-6 boss's schedule (25 points)
网上开户佣金万一安全吗?需要什么资料办理
挡不住了,中国芯片制造产业链的重大突破,5nm设备即将发给台积电
New kernel PHP enterprise website development and construction management system
LeetCode Brushing Diary: 1545. Find the Kth bit in the Nth binary string
Detailed explanation of IK tokenizer
归并排序和计数排序









