c – 编译代码时出错
发布时间:2020-12-16 10:33:52 所属栏目:百科 来源:网络整理
导读:我在编译此代码时收到此错误字符串未声明. #include stdio.h#include stdlib.hint main(){string names;printf("What is your name?n");scanf("%s",names);printf("Your name is %s",names);return 0;} 有人可以告诉我为什么.非常感谢 解决方法 你应该包括
我在编译此代码时收到此错误字符串未声明.
#include <stdio.h> #include <stdlib.h> int main() { string names; printf("What is your name?n"); scanf("%s",&names); printf("Your name is %s",names); return 0; } 有人可以告诉我为什么.非常感谢 解决方法
你应该包括字符串标题:
#include <string> 并且在使用它时不要忘记命名空间std: std::string names; 此外,编码时不要混用C和C.尝试使用std :: cout而不是printf,cin / getline不是scanf. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- c#通过Span / Memory和MemoryMarshal修改interne
- DWR如何获得返回对象
- swift – NSURLSessionUploadTask超时
- asp.net(c#)编程实现将彩色图片变灰阶图片的方法
- ruby – 使用Rspec在单元测试中测试“accepts_ne
- .net – 如何使用Entity Framework连接到Oracle时
- 使用regexp_instr获取字符串中的最后一个数字
- EMBEDDED_driver_nandflash_&_FPGA_8_14
- SQLite Exception, Database Already Closed
- c – 相等的预处理程序测试始终计算为true
热点阅读