2018/3/2 11:30 P.M. Program Written (c + +)

Source: Internet
Author: User

Program Goal: Enter a string to output the string vertically. Use string and dynamically allocate memory mechanisms. The code is as follows:

#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;
}

Compiler: Visual Studio 2015

The compilation error is displayed, but I don't know how to modify it. This is the first record. I hope the great God will not hesitate to enlighten.

Error message:

Severity Code description project file line suppress status
Error C2146 syntax error: missing ";" (in front of the identifier "s") Myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01\myproject_001\myproject_ 001\myproject_001.cpp10
Error C2065 "s": undeclared identifier myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01\ Myproject_001\myproject_001\myproject_001.cpp10
Error C2065 "CIN": undeclared identifier myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01\ Myproject_001\myproject_001\myproject_001.cpp10
Error C2228 the left of ". Getline" must have class/structure/union myproject_001c:\users\administrator\documents\visual Studio 2015\projects\ Myproject_01\myproject_001\myproject_001\myproject_001.cpp10
Error C2065 "s": undeclared identifier myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01\ Myproject_001\myproject_001\myproject_001.cpp11
Error C2065 "s": undeclared identifier myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01\ Myproject_001\myproject_001\myproject_001.cpp12
Error C2065 "s": undeclared identifier myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01\ Myproject_001\myproject_001\myproject_001.cpp13
Error C2065 "s": undeclared identifier myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01\ Myproject_001\myproject_001\myproject_001.cpp14
Error C2065 "cout": undeclared identifier myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01\ Myproject_001\myproject_001\myproject_001.cpp15
Error C2065 "Endl": undeclared identifier myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01\ Myproject_001\myproject_001\myproject_001.cpp15
Error C2065 "CIN": undeclared identifier myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01\ Myproject_001\myproject_001\myproject_001.cpp17
Error C2228 the left side of ". Get" must have class/struct/union myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01 \myproject_001\myproject_001\myproject_001.cpp17
Error C2065 "CIN": undeclared identifier myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01\ Myproject_001\myproject_001\myproject_001.cpp18
Error C2228 the left side of ". Get" must have class/struct/union myproject_001c:\users\administrator\documents\visual Studio 2015\projects\myproject_01 \myproject_001\myproject_001\myproject_001.cpp18

# # # #希望用一个错误来开始我的博客园之旅, only the constant correction, can improve the # #

2018/3/2 11:30 P.M. Program Written (c + +)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.