blob: 0c71d696a3db1e52e6863cea9f230d387f41931b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <iostream>
/*
*
* 3.7
*
* Nothing different happens, pretty much same result. Though auto might just be better so we are sure what type it is.
* Unless the author meant that we were supposed to do char rather than (char&). If we were to just do 'char' type then
* we wouln't be able to modify the characters in the string, therefore the string remains unchanged.
*/
using std::string;
using std::cout;
using std::cin;
using std::cerr;
using std::clog;
using std::endl;
int main () {
string Xer;
cout << "Enter a string" << endl;
cin >> Xer;
for(char &c : Xer) { // Make reference for every character in Xer
c = 'X';
}
cout << Xer << endl;
return 0;
}
|