My specific program basically sparses through a csv file and asks for user input in the form of whether they would like to know how many times goods where delivered by Bike, Car, or Foot, all of this information is stored in the file being read. My issue is I don't know how to build a counter for the code so like when it sparse through the file looking for a string that matches the user input (Bike, Car, or Foot) and then counts all occurences and returns that value to display to the user. Here is my counter method right now that only returns zero and I have no clue what the logic i should use here is. I also think it is important to mention that p is given by a getvariable method so p equals the user input
int transport::counttimes(string p)
{
ifstream inFile;
inFile.open("donationDataFixed.csv");
int c=0;
string s;
string piece;
while(s!=p)
{
stringstream data(s);
getline(data,piece,',');
getline(data,piece,',');
getline(data,piece,',');
getline(data,piece,',');
getline(data,piece,',');
getline(data,piece,',');
getline(data,piece,',');//transportation mode
if (s==p)
{
c=c+1;
}
}
return c;
}