Code:
struct time
{ int t;
int h,m,s;
};
int main()
{
time t;
int totalsecond;
char A[10],B[10];
cout<<"Enter the time Format [12:59:59] = ";
cin.getline(A,10);
int i=0,j=0;
while(A[i]!=':')
{
B[j]=A[i];
i++;
j++;
}
t.h=atoi(B);
i++;
j=0;
while(A[i]!=':')
{
B[j]=A[i];
i++;
j++;
}
t.m=atoi(B);
i++;
j=0;
while(A[i]!='\0')
{
B[j]=A[i];
i++;
j++;
}
t.s=atoi(B);
totalsecond=(t.h*3600)+(t.m*60)+t.s;
cout<<"\n\nTotal Seconds are = "<<totalsecond;
cout<<endl;
getch();
}
Comment