Hi,
I am having a problem accessing the string that is passed to the upr function. I want to make the string an array. I have tried many iterations of code that I thought might work, but to no avail. Could someone please give me some direction?
This line is flagged with &str the culprit.
Code:#include<iostream> #include<string> #include<cctype> using namespace std; void upr(const string & str); int main() { string strinpt; char quit = 'Q'; while (quit != 'q') { cout << "Enter phrase in lower case to be turned into upper case: " << "\n"; getline(cin, strinpt); upr(strinpt); cout << "Do you want stop entry? " << "\n"; cin >> quit; } return 0; } void upr(const string & str) { char* pstr(&str); int i = 0; cout << "Lower to Upper: "; for (i = 0; i < 40; i++) cout << toupper(pstr + i); }




Reply With Quote
