I am reading the book c++ primer (5th edition) and i just dont understand why c in this code has to be a reference :
string s("Hello World!!!");
for (auto &c : s) // here c is a reference
c = toupper(c);
cout << s << endl;
The output of this code is HELLO WORLD!!
Could someone plz explain it to me in an understandable way.
Thank you very much!