Jedno z zadań z thinking in c++. Program ma wczytywać tekst z pliku,
a następnie zamieniać go w jeden łańcuch.
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <conio.h>
using namespace std;
int main() {
vector<string> v;
ifstream in("main.cpp");
string line, poj;
while(getline(in, line))v.push_back(line);
for(unsigned int i = 0; i < v.size(); i++)
{
poj+=v[i];
}
cout << poj;
getch();
return 0;
}
Program wczytuje tekst z pliku do vectora string, a następnie łączy jego elementy. Nie jest to jednak jeden łańcuch. Co zrobić, by usunąć białe znaki ? Lepsze będzie usuwanie już podczas wczytywania czy po nim ?