void CFunct::avgSal()
{
ifstream file ("file.txt");
int found;
int count = 0;
float sum = 0;
float salary = 0;
float avg = 0;
string line;
float tempdip = CLect::salary;
found = CPerson::type.find(tempdip);
while (!file.eof())
{
getline(file,line);
if(found = line.find(tempdip, 0) != line.npos)
{
file >> CLect::salary;
sum += CLect::salary;
count ++;
}
}
cout << sum << endl;
cout << "Average Salary: " << salary << endl;
file.close();
};
Right now this function would be incomplete, but mainly i am stuck with how i would skip the commas in the text file and take out a certain part of the line
Yea but thats the problem, i have to for example "Name,class,classroom" i would only need to print out "class" but i have no idea how to skip the commas in the line and only print out that certain part of the line