Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool HerciDoStruktur(string sherci, HerecT *herci){
- ifstream fherci;
- fherci.open(sherci);
- if (fherci.is_open()){
- string content;
- string contbuffer;
- int i = 0;
- int numrows = 0;
- int numcols = 0;
- while (getline(fherci, content)){
- cout << content << endl;
- cout << "pocet pismen" << content.length();
- for (unsigned int i = 0; i < content.length(); i++){
- if (content[i] == ';'){
- if (numcols == 0){
- cout << " buffer " << contbuffer << endl;
- herci[numrows].idherec = stoi(contbuffer);
- }
- else if (numcols == 1){
- cout << " buffer " << contbuffer << endl;
- herci[numrows].jmeno = contbuffer;
- }
- else if (numcols == 2){
- cout << " buffer " << contbuffer << endl;
- herci[numrows].prijmeni = contbuffer;
- }
- else if (numcols == 3){
- cout << " buffer " << contbuffer << endl;
- herci[numrows].datum_narozeni = contbuffer;
- }
- else if (numcols == 4){
- cout << " buffer " << contbuffer << endl;
- herci[numrows].misto_narozeni = contbuffer;
- }
- contbuffer.clear();
- numcols++;
- }
- else {
- contbuffer += content[i];
- }
- }
- numcols = 0;
- numrows++;
- cout << numrows;
- }
- fherci.close();
- return true;
- }
- else{
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement