1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
#include <iostream>
std::string clean(std::string the_string)
{
char bad[] = {'.', ',', ' ', '|', '\0'};
std::string::size_type n = 0;
while ((n=the_string.find(bad[0], n))!=the_string.npos)
{
the_string.erase(n,1);
}
n = 0;
while ((n=the_string.find(bad[1], n))!=the_string.npos)
{
the_string.erase(n,1);
}
n = 0;
while ((n=the_string.find(bad[2], n))!=the_string.npos)
{
the_string.erase(n,1);
}
n = 0;
while ((n=the_string.find(bad[3], n))!=the_string.npos)
{
the_string.erase(n,1);
}
return the_string;
}
int main(){
char chars[] = "|";
std::ifstream infile("A6.txt");
std::string item,id,code,dob;
getline(infile,dob,'|');
while (!infile.eof()){
getline(infile,item,',');
getline(infile,id,',');
getline(infile,code,',');
getline(infile,dob);
std::cout << "Name:" << item << "\n";
std::cout << "id:" << id << "\n";
std::cout << "Clearence:" << code << "\n";
std::cout << "DoB:" << clean(dob) << "\n\n";
}
return EXIT_SUCCESS;
}
|