c++解决error: ‘strcpy‘ was not declared in this scope

c++解决error: 'strcpy' was not declared in this scope

问题

D:\site\c\hello\main.cpp:15:5: error: 'strcpy' was not declared in this scope
   15 |     strcpy(mine.title, "hilibote");
      |     ^~~~~~
D:\site\c\hello\main.cpp:2:1: note: 'strcpy' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>
mingw32-make.exe[3]: *** [CMakeFiles\hello.dir\build.make:62: CMakeFiles/hello.dir/main.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:72: CMakeFiles/hello.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:84: CMakeFiles/hello.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: hello] Error 2

原因

'strcpy' is defined in header '<cstring>'

解决

使用头文件

#include <cstring>
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值