Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void readClient(Client &client, ifstream &cli, vector <Client> &clients, int &clientID)
- {
- if (cli.is_open())
- {
- string line;
- int counter = 1;
- stringstream ss; // There ss have value.. "" see
- /*getline(cli, line, '\0');
- cout << "FileCli:\n" << line << endl; erase of file..*/
- while (getline(cli, line,'\n'))
- {
- cout << "line cliA: "<< line << endl; // the content of 1º statment (until first '\n', 1º line of client is showed
- ss.str(line);
- string s2 = ss.str();
- cout << "cliD: " << s2 << endl;
- while (getline(ss, line, ';')) // or a condition !trasactions.eof()
- {
- trimSpaces(line);
- cout << "line cliB: " << line << '\t' << endl;//-" << line; << "-" << endl; // the content until first ',' is showed
- // string s = ss.str(); cout << s; s = ss.str("Bom dia!"); cout << s; s = ss.str("\n"); cout << s;
- //ss.str(line); // not altered nothing ... on line!!
- string s = ss.str();
- cout << "cliC: "<< s<<endl;
- switch (counter)
- {
- case 1: // save id of client
- client.id = stoi(line) ; //cli
- if (client.id > clientID) // ss
- clientID = client.id; //faço this mean that idMax is actualized cout << ss;
- counter++;
- ss.ignore(1, ';');
- /*ss.empty();
- ss.clear();*/
- break;
- case 2: // save name of client
- {
- client.name = line;
- counter++;
- ss.ignore(1, ';');
- break;
- }
- case 3: // save money spend by client
- {
- ss >> client.moneySpent;
- counter = 1;
- clients.push_back(client); // put the info, save in struct as element of the vector
- ss.clear();
- cout << "Tamanho = " << clients.size() << endl;
- //cin << cli.
- }
- //case 3: ss >>
- }
- }
- }
- }
- else
- cerr << "error to open clients file" << endl; // with this output fuction,it can show the message with red colour
- }
Add Comment
Please, Sign In to add comment