I am having a similar issue
// Exc_3.cpp - Testing string with refernece
#include <iostream>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
string lowerToUpper(string & ref);
int main()
{
string str;
string constant = "q";
cout << "Enter a string (q to quit): ";
//while (constant != getline(cin, str))
while ('q' != getline(cin, str))
//while (!strcmp(constant, getline(cin,str)))
{
str = lowerToUpper(str);
cout << str << endl;
cout << "Enter a string (q to quit): ";
}
}
string lowerToUpper(string & ref)
{
for(int i = 0; i < ref.size(); i++)
{
string[i] = toupper(string[i]);
}
}
I have tried 3 different ways, and can't get them to work. Kinda confused on your explantion....