We just started working on functions in class this week. For this assignment we had to write some function that won't accept 0 or anything above 24 hours. While I think I have that part working, I'm running into issues when I try to use said function in main.
Below is my code so far:
#include<iostream>
using namespace std;
int hr = 0;
int mn = 0;
int sec = 0;
int totalSec = 0;
time(int hr, int mn, int sec, int totalSec)
{
    if (cin.fail() == 0)
    {
        cout << "you cant have zeros" << endl;
    }
    else if (hr > 24)
    {
        cout << "You cant go over 24 hours"<< endl;
    }
    else
    {
        // hours * minutes * seconds then add minutes * seconds 
        // added to the seconds for totalSec
        totalSec = (hr * 60) * 60 + (mn * 60) + sec;
        return totalSec;
    }
}
int main()
{
    cout << "What time is it"<<endl;
    cin >> hr;
    cin >> mn; 
    cin >> sec;
    cout << hr << " Hours," << mn << " Minutes," << sec << " Seconds past midnight!"<< endl;
    totalSec = time(int totalSec);
    cout << " or " << totalSec << " seconds till midnight." << endl;
}
 
     
     
    