[英]I keep getting a syntax error but I am not sure why
我不知道为什么我得到错误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;
};
我怀疑问题在这里:
std::string::size_type c == 0;
这应该是:
std::string::size_type c = 0;
这一行:
std::string::size_type c == 0;
应该:
std::string::size_type c = 0;
你还没有初始化'c'。
std :: string :: size_type c == 0;
应该
std :: string :: size_type c = 0;
问题是
std::string::size_type c == 0;
应该什么时候
std::string::size_type c = 0;
它需要是单个相等的运算符(赋值运算符)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.