程序目标:输入一个字符串,竖向输出该字符串。使用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. sql 查询 ORA-12170 TNS 连接超时特殊原因

    一般对于ORA-12170这个问题 1 看数据ip 是否能ping通 2 数据库服务是否启动 3 数据库服务所在服务器防火墙 然而当你能进去数据,而报这个这错时: 1 看代码中数据库连接是写错 2 如 ...

  2. 流API--使用并行流

    这篇博客一起来研究下使用并行流.借组多核处理器并行执行代码可以显著提高性能,但是并行编程可能十分复杂且容易出错,流API提供的好处之一是能够轻松可靠的并行执行一些操作.请求并行处理流,首先要获得一个并 ...

  3. j2e应用相关技术

    j2e应用相关技术 轻量级j2e应用以传统的jsp作为变现层技术,以一系列开源框架作为MVC层,中间件,持久层解决方案,并将这些开源框架有机组合在一起,使得j2e具有高度的可扩展性,可维护性. ser ...

  4. MySQL中查询表及索引大小的方法

    查询MySQL表的大小及索引大小可以通过系统库information_schema中的TABLES表来实现. 该表常用的一些字段: TABLE_SCHEMA:数据库名TABLE_NAME:表名ENGI ...

  5. MySQL5.6安装(RPM)笔记

    1. 检查MySQL是否安装,如果有安装,则移除(rpm –e 名称)[root@localhost ~]# rpm -qa | grep -i mysqlmysql-libs-xxxxxxxxxx. ...

  6. jenkins插件安装与升级[三]

    标签(linux): jenkins 笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 默认的插件 Folders Plugin OWASP Markup Form ...

  7. CSS——元素分类

    1.标签元素被分为三大类:块状元素.内联元素和内联块元素. (1)常见块状元素有:<div>.<p>.<h1>...<h6>.<ol>.&l ...

  8. 服务器开发之CGI后门

    1.html代码 <form id = "form" name="form" method="post" action=". ...

  9. samephore()信号量跨线程通信

    samephore1: #include <stdio.h> #include <stdlib.h> #include <Windows.h> ] = " ...

  10. [PHP]全局使用 Composer 组件的思路

    /** * 全局使用 composer 组件的步骤: * * 1. 建一个包含所有需要全局使用的composer包的项目. * 如:globalVendor/ * composer init 初始化 ...