2018/3/2晚11点30分写的程序(C++)

2018-06-17 21:08:04来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

程序目标:输入一个字符串,竖向输出该字符串。使用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
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:详解HASH【string】

下一篇:BZOJ4819: [Sdoi2017]新生舞会(01分数规划)