ADDING INT TO STRING C++

can somebody tell me whats wrong with my program ?
it always says that coundnt find match operator ?
what can i do ?
i want to multiply string pay to int HOURS


thanks a lot

#include<iostream>
#include<fstream>
#include<string>

using namespace std;

int main () {
system("color 8e");
string ID,name, address,No, pos ,pay, hanap;
string hours;
string ot;
string a , b,c,d,e,f,g,h,i,j,k,l;

ifstream OMG;
OMG.open("Employee.txt", ios::in );






cout << "Enter employee ID you want to search: ";
cin >> hanap;

while (getline(OMG, ID, ','),
getline(OMG, name, ','),
getline(OMG, address, ','),
getline(OMG, No, ','),
getline(OMG, pos, ','),
getline(OMG, pay, '\n'))

if (hanap == ID){
cout << "\nID: " << ID << endl;
cout << "Name: " << name << endl;
cout << "Adress: " << address << endl;
cout << "Contact No: " << No << endl;
cout << "Position: " << pos << endl;
cout << "Pay: "<< pay <<endl;

cout << "****************************\n";
cout << " EARNINGS "<<endl;
cout << "No of Hrs Work : ";
cin >> hours;
cout << "OT hours work : ";
cin >> ot;


cout << "*****************************\n";
cout << " DEDUCTIONS "<<endl;
cout << "Tax: "<<endl;
cout <<"SSS: "<<endl;
cout <<"PhilHealth: "<<endl;
cout << "*****************************\n";
cout << " SUMMARY "<<endl;
cout << "Gross Income: "<<pay * hours<<endl;
cout << "Net Income: "<<endl;



}








OMG.close();


system("pause");







}


Last edited on
Well, how would you define the result of multiplying "milk" with "peanuts"?
"mpielaknuts" or "mmmmmmmiiiiiiilllllllkkkkkkk"?
If you want to convert a string to an integer, use the following:
 
std::stoi(yourString);    // s to i; string to int 
@bugbyte sir ? where should i put that ?
where ever you want to calculate with int values in strings. Who should know better than you? Maybe here?
 
cout << "Gross Income: "<< stoi(pay) * stoi(hours) << '\n';

Maybe I should add, you should validate input before processing it.
Last edited on
Topic archived. No new replies allowed.