#include #include #include #include #include using namespace std; int main() { string line; ifstream mydata("string-data.txt"); string product; string price; int pos; // Check that the file was opened successfully. if(mydata==NULL) { cerr << "FILE NOT FOUND!" << endl; exit(-1); } // While mydata did not reach the end of the file. while(!mydata.eof()) { getline(mydata,line); //cout << "Processing: " << line << endl; pos=line.find(";",0); product=line.substr(0,pos); price=line.substr(pos+1,line.length()-(pos+1)); //cout << "Product: " << product << " Price: " << price << endl; cout << "Product: " << left << setw(20) << product << " Price: " << setw(6) << right << price << endl; } mydata.close(); }