I tryed to modify the "if......." (if (nota.compare(12,3,"5 L") == 0) cout << "trovato" << endl;)
but got error:
terminate called after throwing an instance of 'out of range'
what <> : basic string::compare
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
int main()
{
string nota;
ifstream leggi("akagi.txt");
if (leggi)
{
while (!leggi.eof())
{
getline(leggi, nota);
int len = nota.length();
for(int x=0;x< len; x++)
{
if (nota[x] == '5')
{
if (nota[x+2] == 'R')// used +2 because of the space between the 5 and R
nota[x] = '4';
}
}
cout << nota << endl;
}
}
leggi.close();
return 0;
}