Is there a more succinct way to use toupper? to make one char uppercase in string?

Jul 6, 2015 at 8:05pm
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;
}
Jul 6, 2015 at 8:18pm
SUre. replace c with toupper (name[2]); directly and delete line declaring variable c.
Jul 6, 2015 at 8:20pm
 
name[2] = toupper(name[2]);
Jul 6, 2015 at 8:20pm
you mean?

 
name[2] = toupper(name[2]); 
Jul 7, 2015 at 4:18am
@disch did you see we posted at the same time? And also there is a duplicate forum post now?

Just thought that was funny.
Jul 7, 2015 at 4:24am
looks like it was deleted :)
Last edited on Jul 7, 2015 at 4:25am
Topic archived. No new replies allowed.