程序目标:输入一个字符串,竖向输出该字符串。使用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

####希望用一个错误来开始我的博客园之旅,只有不停的纠错,才能提高####

2018/3/2晚11点30分写的程序(C++)的更多相关文章

  1. 大一C语言学习笔记(11)---编程篇--写一个程序,可以获取从键盘上输入的的三个数,并能够判断是否可以以这三个数字作为边长来构成一个三角形,如果可以的话,输出此三角形的周长及面积,要求 0 bug;

    考核内容: 写一个程序,可以获取从键盘上输入的的三个数,并能够判断是否可以以这三个数字作为边长来构成一个三角形,如果可以的话,输出此三角形的周长及面积: 答案: #include<stdio.h ...

  2. PTA 07-图5 Saving James Bond - Hard Version (30分)

    07-图5 Saving James Bond - Hard Version   (30分) This time let us consider the situation in the movie ...

  3. PAT A1127 ZigZagging on a Tree (30 分)——二叉树,建树,层序遍历

    Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can ...

  4. 1127 ZigZagging on a Tree (30 分)

    1127 ZigZagging on a Tree (30 分) Suppose that all the keys in a binary tree are distinct positive in ...

  5. 【PAT】1053 Path of Equal Weight(30 分)

    1053 Path of Equal Weight(30 分) Given a non-empty tree with root R, and with weight W​i​​ assigned t ...

  6. 1053 Path of Equal Weight (30 分)

    Given a non-empty tree with root R, and with weight W​i​​ assigned to each tree node T​i​​. The weig ...

  7. pta5-9 Huffman Codes (30分)

    5-9 Huffman Codes   (30分) In 1953, David A. Huffman published his paper "A Method for the Const ...

  8. A1095 Cars on Campus (30)(30 分)

    A1095 Cars on Campus (30)(30 分) Zhejiang University has 6 campuses and a lot of gates. From each gat ...

  9. PTA 11-散列4 Hard Version (30分)

    题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/680 5-18 Hashing - Hard Version   (30分) Given ...

随机推荐

  1. confirm显示数组中的内容时,总是带一个逗号分隔的解决方法

    问题的关键 就是在给confirm显示之前,将数组转换成字符串,并以每个数组的元素为一个字符串,加上一个换行回车符即可: 代码中的背景色 为关键的点 <script type="tex ...

  2. Python之算法

    一.什么算法 算法:一个计算过程,解决问题的方法 二.时间复杂度 看代码:                                                               ...

  3. SQL Server判断小数位数

    项目中需要写一规则,目的是判断数值的小数位数,可以分为2中情况. 1.直接以小数点为分界点,小数点后的数据表示小数的位数,此种情况比较简单,直接使用CHARINDEX函数就可以搞定 其中CHARIND ...

  4. transfer-webpack-plugin最简使用示例

    转移文件的插件 加载插件 $ npm install transfer-webpack-plugin --save-dev API new CopyWebpackPlugin(patterns: Ar ...

  5. 01_Python入门

    Python介绍 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆(中文名字:龟叔)为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程 ...

  6. LVS、Nginx和HAProxy负载均衡器对比总结

    LVS特点: 1.抗负载能力强,使用IP负载均衡技术,只做分发,所以LVS本身并没有多少流量产生: 2.稳定性.可靠性好,自身有完美的热备方案:(如:LVS+Keepalived) 3.应用范围比较广 ...

  7. python中的线程

    1.线程的创建 1.1 通过thread类直接创建 import threading import time def foo(n): time.sleep(n) print("foo fun ...

  8. ABP官方文档翻译 4.4 授权

    授权 介绍 关于IPermissionChecker 定义权限 检查权限 使用AbpAuthorize特性 AbpAuthorize特性注意点 抑制授权 使用IPermissionChecker 在R ...

  9. java 世界中Annotation

    java 世界中Annotation 在github上开始汇总一些自己学习,收集,总结,经验的一些信息,有利于跟踪,修改,提升.如果你感兴趣 可以关注一下,也可以提供自己的内容进来. https:// ...

  10. trie 树 模板

    #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> ...