Is there a more succinct way to use toupper? to make one char uppercase in string?
I feel like this could be written with out declaring a char variable?
or no?
1 2 3 4 5 6 7 8 9 10 11 12
|
#include <iostream>
using namespace std;
int main() {
std::string name;
cout << name << endl;
char c = toupper (name[2]);
name[2] = c;
cout << name << endl;
return 0;
}
|
SUre. replace c with toupper (name[2]);
directly and delete line declaring variable c.
|
name[2] = toupper(name[2]);
|
you mean?
|
name[2] = toupper(name[2]);
|
@disch did you see we posted at the same time? And also there is a duplicate forum post now?
Just thought that was funny.
looks like it was deleted :)
Last edited on
Topic archived. No new replies allowed.