Witam chce by mój program wczytywał z pliku dane (10 słów) później je przypisuje do vectora a następnie ma je sprawdzić czy nie mam tam na takich znaków jak *, $, % itd. I jak na takie coś natrafi to ma ma skasować dany vector. I tu pojawia się mój problem z find. Mianowicie ma błąd konwertowania.
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
void openFile ( fstream& file ); //zaladowanie pliku
vector<string> assignment ( fstream& file );
void checkingValues ( vector<string> finishWords );
int main()
{
fstream file;
openFile( file );
vector<string> finishWords = assignment( file );
for (int i =0 ; i < finishWords.size() ; ++i)
{
cout << "to sa moje slowa " << finishWords[i] << endl;
}
checkingValues( finishWords );
return 0;
}
//==========================================================================================
void openFile( fstream& file )
{
file.open( "dane.txt" , ios::in );
if ( file.good() == false )
{
cout << "Plik nie istnieje" << endl;
}
}
//==========================================================================================
vector<string> assignment( fstream& file )
{
string line;
vector<string> words;
while( getline( file , line ) )
{
words.push_back(line);
}
return words;
}
//==========================================================================================
void checkingValues ( vector<string> finishWords )
{
// char copyTab[10];
for ( int i = 0 ; i < finishWords.size() ; ++i )
{
if ( find( finishWords.begin() , finishWords.end() , '!' || '@' || '#' || '$' || '%' || '^' || '&' || '*' ) )
{
finishWords.erase(finishWords.begin()+i);
}
// copyTab = finishWords[i];
}
}
Najpierw chciałem do tablicy char skopiować każdą daną po kolei i ja sprawdzać do tab[0] do tab[9] ale nie mogłem skopiować vectora do tablicy.