I am trying to make a program that can take a string from a file, and convert it to 4 predefined integers.
For now, I am attempting the stage after extracting the line from the document, to split it up into the wanted parts.
""
were creating issues, but it was easily solved by std::replace
'ing the offending characters. Eventually, the source of the string will be directly from the file, but when inputting it manually, it automatically breaks the terminal:
string: <bounds minlat="51.4374338" minlon="-0.2090608" maxlat="51.5663602" maxlon="-0.0019455"/><bounds minlat="51.4374338" minlon="-0.2090608" maxlat="51.5663602" maxlon="-0.0019455"/>
:bounds
And somehow, with no help, it breaks in a weirder manner:
string: <bounds minlat="51.4374338" minlon="-0.2090608" maxlat="51.5663602" maxlon="-0.0019455"/><bounds minlat="51.4374338" minlon="-0.2090608" maxlat="51.5663602" maxlon="-0.0019455"/>
<bounds
If someone has an indication of how to approach this, I would be grateful. Googling "Input sanatisation" only gives ignoring numbers and special characters, which this input still breaks.
Full experimentation code below, the used input is in the //comment
:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
// <bounds minlat="51.4374338" minlon="-0.2090608" maxlat="51.5663602" maxlon="-0.0019455"/>
string line6;
cout << "string: "; cin >> line6;
std::replace( line6.begin(), line6.end(), '<', ':');
std::replace( line6.begin(), line6.end(), '>', ';');
std::replace( line6.begin(), line6.end(), '"', '_');
cout << "\n" << line6;
return 0;
}