2018/3/2晚11点30分写的程序(C++)
2018-06-17 21:08:04来源:未知 阅读 ()
程序目标:输入一个字符串,竖向输出该字符串。使用string和动态分配内存机制。代码如下:
#include<iostream>
#include "stdafx.h"
#include<cstring>
int main()
{
using namespace std;
string s= cin.getline;
char * a = new char[sizeof(s)];
for (int m = 0;m < sizeof(s);m++)
a[m] = s[m];
for (int n = 0;n < sizeof(s);n++)
cout << a[n] << endl;
delete[] a;
cin.get();
cin.get();
return 0;
}
编译器:Visual Studio 2015
显示编译错误,但是不知道怎么修改。先记录在这。希望大神不吝赐教。
错误信息:
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 C2146 语法错误: 缺少“;”(在标识符“s”的前面) MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 10
错误 C2065 “s”: 未声明的标识符 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 10
错误 C2065 “cin”: 未声明的标识符 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 10
错误 C2228 “.getline”的左边必须有类/结构/联合 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 10
错误 C2065 “s”: 未声明的标识符 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 11
错误 C2065 “s”: 未声明的标识符 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 12
错误 C2065 “s”: 未声明的标识符 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 13
错误 C2065 “s”: 未声明的标识符 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 14
错误 C2065 “cout”: 未声明的标识符 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 15
错误 C2065 “endl”: 未声明的标识符 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 15
错误 C2065 “cin”: 未声明的标识符 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 17
错误 C2228 “.get”的左边必须有类/结构/联合 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 17
错误 C2065 “cin”: 未声明的标识符 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 18
错误 C2228 “.get”的左边必须有类/结构/联合 MyProject_001 c:\users\administrator\documents\visual studio 2015\projects\myproject_01\myproject_001\myproject_001\myproject_001.cpp 18
####希望用一个错误来开始我的博客园之旅,只有不停的纠错,才能提高####
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- Noip2018Day1T3 赛道修建 2019-09-30
- IEEE浮点表示 (原发布 csdn 2018-10-14 10:29:33) 2019-09-08
- 201803-2 碰撞的小球 2019-09-08
- 2018.12.4数据结构上机考试 2018-12-04
- 【2018.10.11 C与C++基础】C Preprocessor的功能及缺陷(草 2018-12-04
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash