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 + +)