Zdravim mam problem... V C++ jsem si vytvoril program pro prekladani slov...tedy prekladac a z nejakeho duvodu mi nefunguje a ja nevim proc...mohl by mi nekdo prosim poradit?...diky
#include <utility>
#include <string>
#include <iostream>
#include <vector>
using namespace std;
int main () {
vector<pair<string, string> > translations;
translations.push_back(make_pair("tělo", "body"));
translations.push_back(make_pair("odstavec", "p"));
string line;
string content;
content = "";
while (getline(cin, line)) {
content += line+'\n';
}
for (vector<pair<string, string> >::iterator it = translations.begin() ; it != translations.end(); ++it) {
size_t index = 0;
while (true) {
index = content.find(it->first, index);
if (index == string::npos) {
break;
}
content.replace(index, it->first.length(), it->second);
index += it->second.length();
}
}
cout << content;
}