I am writing a function that will take time as three integer arguments (for hours,minutes, and seconds), and returns the number of seconds since the last time the clock "struck 12". I will then use this function to calculate the amount of time in seconds between two times, both of which are within on 12-hour cycle of the clock. I am getting error messages like crazy. Any advice would be appreciated.
#include <iostream>
using namespace std;
int get_sec(int, int, int); //function prototype
int main()
{
int hh, mm, ss;
cout << "Enter Hour, Minutes, and Seconds: " << endl;
cin >> hh >> mm >> ss;
cout <<"Seconds Since 12: "<< get_sec(hh,mm,ss) <<endl;
int hh1, mm1, ss1;
cout <<"Enter First Time Hour, Minute, and Second: " <<get_sec(hh,mm,ss)<<endl;
cin >> hh1 >> mm1 >> ss1;
int hh2,mm2, ss2;
cout <<"Enter Second Time Hour, Minute, and Second:"<<get_sec(hh,mm,ss)<<endl;
cin>> hh2 >> mm2 >> ss2>>
int d;
d = get_sec(hh1, mm1, ss1) -get_sec(hh2, mm2, ss2);
cout << "Difference between two times: " <<="0)";
}
sec; return min; + hr="hr" sec="sec" ; 60 * min="min"; { sec)
int min, hr, (int get_sec 0; <<d<< ? times: two between ?Difference << cout -1; d="d" (d if>
return 0;
}
The error messages that I am getting are:
error C2062: type 'int' unexpected
error C2065: 'd' : undeclared identifier
error C2676: binary '<<=' : 'class std::basic_ostream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to
the predefined operator
warning C4508: 'main' : function should return a value; 'void' return type assumed
error C2501: 'sec' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before 'return'
error C2143: syntax error : missing ';' before '+'
error C2143: syntax error : missing ';' before 'constant'
error C2447: missing function header (old-style formal list?)