我不知道为什么我得到错误C2143:语法错误:缺少';' 在'==之前如果有人会解释我的错误,我将不胜感激.
#include <iostream>
#include <string>
#include <cstdlib>
int main() {
std::cout << "What is your name? ";
std::string name;
std::cin >> name;
const std::string greeting = "Hello " + name + " !";
//
const int pad = 1;
const int rows = pad * 2 + 3;
std::cout << std::endl;
//
int r = 0;
while (r != rows) {
std::cout << std::endl;
++r;
}
//
std::string::size_type cols = greeting.size() + pad * 2 + 2;
std::string::size_type c == 0;
while (c != cols) {
if (r == 0 || r == rows -1 || c == 0 || c == cols -1) {
} else {
}
}
std::system("pause");
return 0;
};
Run Code Online (Sandbox Code Playgroud)
Ree*_*sey 10
我怀疑问题在这里:
std::string::size_type c == 0;
Run Code Online (Sandbox Code Playgroud)
这应该是:
std::string::size_type c = 0;
Run Code Online (Sandbox Code Playgroud)
这一行:
std::string::size_type c == 0;
Run Code Online (Sandbox Code Playgroud)
应该:
std::string::size_type c = 0;
Run Code Online (Sandbox Code Playgroud)