error C2061: syntax error : identifier 'string'

本文介绍了解决C++编程中因未引入标准命名空间而导致的字符串使用报错问题。通过在程序开头添加包含指令及命名空间使用声明,可以有效避免此类错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在相应的报错文件中加入:

#include<string>

using namespace std;


报错的原因是一般没有加入using namespace std; 导致的

main.c(64): error C141: syntax error near 'u8', expected 'sizeof' main.c(64): error C202: 'i': undefined identifier main.c(64): error C202: 'i': undefined identifier main.c(64): error C202: 'i': undefined identifier main.c(64): error C141: syntax error near ')', expected ';' main.c(66): error C202: 'i': undefined identifier main.c(92): error C141: syntax error near 'u8', expected '__asm' main.c(92): error C202: 'num': undefined identifier main.c(97): error C141: syntax error near 'float', expected '__asm' main.c(97): error C202: 'divisor': undefined identifier main.c(98): error C202: 'num': undefined identifier main.c(100): error C202: 'num': undefined identifier main.c(104): error C141: syntax error near 'char', expected '__asm' main.c(104): error C202: 'temp': undefined identifier main.c(105): error C202: 'temp': undefined identifier main.c(108): error C141: syntax error near 'u8', expected '__asm' main.c(108): error C202: 'len': undefined identifier main.c(109): error C202: 'len': undefined identifier main.c(110): error C202: 'len': undefined identifier main.c(111): error C202: 'len': undefined identifier main.c(113): error C202: 'len': undefined identifier main.c(114): error C202: 'len': undefined identifier main.c(115): error C202: 'len': undefined identifier main.c(119): error C202: 'len': undefined identifier main.c(120): error C141: syntax error near 'u8', expected 'sizeof' main.c(120): error C202: 'i': undefined identifier main.c(120): error C202: 'i': undefined identifier main.c(120): error C202: 'i': undefined identifier main.c(120): error C141: syntax error near ')', expected ';' main.c(122): error C202: 'i': undefined identifier main.c(122): error C202: 'i': undefined identifier main.c(124): error C202: 'i': undefined identifier main.c(169): error C141: syntax error near 'char', expected '__asm' main.c(169): error C202: 'temp': undefined identifier main.c(170): error C202: 'temp': undefined identifier main.c(171): error C141: syntax error near 'u8', expected '__asm' main.c(171): error C202: 'len': undefined identifier main.c(172): error C202: 'len': undefined identifier main.c(173): error C202: 'len': undefined identifier main.c(174): error C202: 'len': undefined identifier main.c(176): error C202: 'len': undefined identifier main.c(177): error C202: 'len': undefined identifier main.c(178): error C202: 'len': undefined identifier main.c(179): error C202: 'len': undefined identifier main.c(183): error C202: 'len': undefined identifier main.c(184): error C141: syntax error near 'u8', expected 'sizeof' main.c(184): error C202: 'i': undefined identifier main.c(184): error C202: 'i': undefined identifier main.c(184): error C202: 'i': undefined identifier main.c(184): error C141: syntax error near ')', expected ';' main.c(186): error C202: 'i': undefined identifier main.c(186): error C202: 'i': undefined identifier main.c(188): error C202: 'i': undefined identifier 出现了更多的错误,请修改
06-09
我用了上述你给我提供的代码,出现了下列问题,请根据这些问题修改代码并且将修改后的完整代码发给我 222.c(107): error C141: syntax error near 'unsigned', expected '__asm' 222.c(107): error C141: syntax error near '}', expected ';' 222.c(108): error C202: 'days_in_month': undefined identifier 222.c(110): error C202: 'days_in_month': undefined identifier 222.c(169): error C141: syntax error near 'unsigned', expected '__asm' 222.c(169): error C202: 'LSB': undefined identifier 222.c(170): error C141: syntax error near 'unsigned', expected '__asm' 222.c(170): error C202: 'MSB': undefined identifier 222.c(171): error C202: 'MSB': undefined identifier 222.c(286): error C141: syntax error near 'unsigned', expected '__asm' 222.c(286): error C202: 'seconds': undefined identifier 222.c(287): error C141: syntax error near 'unsigned', expected '__asm' 222.c(287): error C202: 'ms': undefined identifier 222.c(291): error C202: 'seconds': undefined identifier 222.c(476): error C141: syntax error near 'static', expected '__asm' 222.c(476): error C202: 'temp_counter': undefined identifier 222.c(477): error C202: 'temp_counter': undefined identifier 222.c(478): error C202: 'temp_counter': undefined identifier 222.c(491): error C141: syntax error near 'static', expected '__asm' 222.c(491): error C202: 'ms_counter': undefined identifier 222.c(492): error C141: syntax error near 'static', expected '__asm' 222.c(492): error C202: 'sec_counter': undefined identifier 222.c(494): error C202: 'ms_counter': undefined identifier 222.c(503): error C202: 'ms_counter': undefined identifier 222.c(504): error C202: 'ms_counter': undefined identifier Target not created.
06-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值