简体   繁体   中英

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

I am not sure why I get the error C2143: syntax error : missing ';' before '==' Would be most grateful if somebody would explain my error.

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

I suspect the problem is here:

std::string::size_type c == 0;

That should probably be:

std::string::size_type c = 0;

This line:

std::string::size_type c == 0;

should be:

std::string::size_type c = 0;

You have not initialized 'c' yet.

std::string::size_type c == 0;

should be

std::string::size_type c = 0;

problem is

std::string::size_type c == 0; 

when should be

std::string::size_type c = 0;

it needs to be single equal operator(assignment operator)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM