I'm attempting to make a basic user interface that is not case-sensitive for the sake of convenience. To do this, I've made a converter class that makes the string uppercase, but I've stumbled on an issue. After using the class, an if statement in main() is supposed to interpret the message from the converter, but it only reads what the original input was, not it's uppercase counterpart, and I've attempted to return the converted string directly from the converter, but it will not let me.
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
string response;
//converts responses to upper-case
void convert(string response) {
for (int i = 0; i < response.length(); i++) {
response[i] = toupper(response[i]);
}
}
//main dialogue
int main() {
cout << "How are you?: ";
getline(cin, response);
convert(response);
if (response == "GOOD") {
cout << "Response 1./l";
}
else {
cout << "Response 2./l";
}
}
I'm very new to C++, so I apologize if the mistake was an easy one to fix or if I have difficulty understanding the solution.