All Discussions (4)

Sort by

How to use for each loop in c++

 {Code}

#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main() {
string str("hello world!");
for (auto &c : str)
c = toupper(c);
cout << str;
return 0;
}

This c++ code does not compile. Error msg: main.cpp:21: error: a f

Read more…
1 Reply · Reply by SK-MSSE Jul 14