Vote count:
0
I'm trying to do a simple program where the user inputs a string with his/her name, then if the string is equal to a certain name, it executes different commands.
It's something like this:
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main() {
string input = "";
cout << "What's your name?:\n>";
getline(cin, input);
if(input = "Micaela"){
cout << "You're the best" << input << endl << endl;
}
else
cout << "You kinda suck" << input << endl << endl;
return 0;
}
When compiling, I get the following error:
13 22 C:\Users\Francisco\Desktop\cpp\holanena.cpp [Error] could not convert 'input.std::basic_string<_CharT, _Traits, _Alloc>::operator=, std::allocator >(((const char*)"Micaela"))' from 'std::basic_string' to 'bool'
asked 1 min ago
C++ Could not convert input string when using cin and variables
Aucun commentaire:
Enregistrer un commentaire