我一直得到一个语法错误,但我不知道为什么

I keep getting a syntax error but I am not sure why

本文关键字:错误 语法 为什么 我不知道 一个 一直      更新时间:2023-10-16

我不知道为什么我得到错误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;

它需要是单个相等运算符(赋值运算符)