Hi there, I have used the advice in this forum to solve most of the problems I have had so far but I am running out of time on this final assignment (due this evening) and I am stumped.
I need to write a function that takes a time in seconds and returns a formatted string (hh:mm:ss)
I am specifically not permitted to use an array (not that I know how to use one yet)
My code looks like this right now. I can easily obtain the components of the string in integer formatbut I cannot figure out how to pass them to the string with zero padding et al..
Help would be greatly appreciated.
#include <iostream>
#include <iomanip>
using namespace std;
int FormatTime(int ts, string formatted time);
int main ()
{
int totalSeconds;
string formattedTime;
cout << "*********************************************************\n";
cout << "*\tWelcome to the Time Re-format application\t*\n";
cout << "*********************************************************\n\n\n";
cout << "Please enter a time in seconds and press <Enter>: ";
cin >> totalSeconds;
FormatTime(totalSeconds, formattedTime);
cout << "\n\nThe time in seconds you entered ("<< totalSeconds << " seconds) is equivelant to " << formattedTime;
cout <<"\n\nThank you for using the time converter\n\n";
return 0;
}
int FormatTime(int ts, string formattedTime)
{
int hr, min, sec;
hr = ts / 360;
ts = ts % 360;
min = ts / 60;
sec = ts % 60;
return (formattedTime);
}