function not doing all the math

so i need to have two times calculated into minutes and find the difference my code only ignores the hours and just does the minutes if someone could find my error here that would be great

#include <iostream>
#include <cmath>
using namespace std;

void readTime(int& hr, int& min, bool& isAM)
{char extra1, extra2, ampm;
cout << "Enter the Time:";
cin >> hr >> extra1 >> min >> ampm >> extra2;
if (ampm == 'a')
isAM = true;
else
isAM = false;
if ((hr=12) && (isAM=true))
hr=0;
}

int covtTime (int hourP,int minuteP,bool amP, int hourF, int minuteF, bool amF)
{int totalMP, totalMF, totalDiff;
if (amP = true)
totalMP = (hourP * 60) + minuteP;
else
totalMP = (hourP * 60) + minuteP + 720;
if (amF = true)
totalMF = (hourF * 60) + minuteF;
else
totalMF = (hourF * 60) + minuteF + 720;
totalDiff = totalMF - totalMP;
return totalDiff;
}

int main()
{
int hourP, minuteP, hourF, minuteF, totalDiff;
bool amP, amF;
readTime (hourP, minuteP, amP);
readTime (hourF, minuteF, amF);
totalDiff = covtTime (hourP, minuteP, amP, hourF, minuteF, amF);
cout << "The Time Difference is " << totalDiff << "minutes" << endl;
}
Please don't cross-post the same content to multiple forums in the future. One is enough.

Follow-ups should go here: http://www.cplusplus.com/forum/general/200290/
Topic archived. No new replies allowed.