I am a beginner and I am practicing C++ on UVa.
Problem link: P458
My IDE is showing an error in line 15 decoded = decoded + (s[i] - 7);
My code:
#include <iostream> #include <string> using namespace std; int main() { string s; while (cin >> s) { string decoded; int len = s.length(); for (int i = 0; i < len; i++) { decoded = decoded + (s[i] - 7); //15 no line } cout << decoded << endl; } return 0; } But when I write the line like this decoded += (s[i] - 7); it shows no error.
Please explain why this is happening?
Thanks in advance.