Mam taką funkcje :
void dodajStudent(int *indeks, string *imie, string *nazwisko, int *x, struct student *tab){
fstream tabela;
string polecenie;
int atrybut1;
string atrybut2,atrubut3;
getline(cin,polecenie);
usunZnaki(&polecenie);
tabela.open("tymczasowy.txt", ios::in | ios::trunc | ios::out);
tabela << polecenie;
tabela >> atrybut1;
cout << atrybut1;
}
i problem jest z tym, że zamiast tego co powinno być atrybutem1 ( w pliku jest to 123, ogolnie caly plik zawiera " 123 xxx yyy "), to przypisuje mi niepoprawną wartość, wie ktoś co może być problemem? Funkcja usunZnaki jakby byla potrzebna to:
void usunZnaki(string *polecenie){
for ( int i = 0; i < (*polecenie).length(); i ++){
if ((*polecenie)[i] == ','){
(*polecenie).replace(i,1," ");
}
if ((*polecenie)[i] == '('){
(*polecenie).replace(i,1,"");
}
if ((*polecenie)[i] == ')'){
(*polecenie).replace(i,1,"");
}
}
}
polecenie jest postaci - "(liczba,string,string)"
Liczę na pomoc ; ).