I have rewritten the code. Now I am getting the following error message:error C2239: unexpected token '{' following declaration of 'main'. Please help.

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. Any advice would be appreciated.

Code:
```#include <iostream>
#define  SecondsPerHour    3600
#define  SecondsPerMinute  60
#define  MinutesPerHour    60

int      main
{

int     hh,                   // hours
mm,                   // minutes
ss,                   // seconds

begin_sec,  end_sec,  // times converted
sec_elapsed;          // difference between times

char    colon1, colon2;

printf( "Please enter a start time (HH:MM:SS) --> " );
scanf ( "%d%c%d%c%d", &hh, &colon1, &mm, &colon2, &ss);

// convert start time to seconds by calling on function
begin_sec = Time_in_Seconds(hh,mm,ss);

printf( "Please enter an end time  (HH:MM:SS) --> " );
scanf ( "%d%c%d%c%d", &hh, &colon1, &mm, &colon2, &ss);

// calls on function that will convert entered time to seconds

end_sec = Time_in_Seconds(hh, mm, ss);

// calculate time difference
sec_elapsed = end_sec - begin_sec;

return (0);
}```

2. You forgot the parameter list:
Code:
```int main ( void )
{```

3. Change this line:

int main

to this:

int main()

And, change this line:

return (0);

to this:

return 0;

4. Originally posted by 7stud

And, change this line:

return (0);

to this:

return 0;
What's wrong with the braces? Nothing.
It's even legal to write something like this
Code:
`int (((i)));`

5. Thanks for the insight. I'll try to remember that the next time I need to declare an int variable.

6. I have changed all the suggestions you have made. And I am still getting the same error messages.

7. #include <iostream>
#define SecondsPerHour 3600
#define SecondsPerMinute 60
#define MinutesPerHour 60

int main ()
{

int hh, // hours
mm, // minutes
ss, // seconds

begin_sec, end_sec, // times converted
sec_elapsed; // difference between times

std::cout<< "Please enter a start time (HH:MM:SS): ";//start time
std::cin >>"%d%d%d", &hh, &mm,&ss;

std::cin>>"%d%d%d", &hh,&mm,&ss;

sec_elapsed = end_sec - begin_sec;// calculate time difference

// This function calculates the number of seconds when given a time in Hours:Minutes:Seconds */

int Time_in_Seconds( int hh, int mm, int ss);

int time_in_sec;

time_in_sec = (hh * SecondsPerHour) +
(mm * SecondsPerMinute)+(ss);// converts standard time into seconds

begin_sec = Time_in_Seconds(hh,mm,ss); // convert start time to seconds
end_sec = Time_in_Seconds(hh, mm, ss); // calls on function that will convert entered time to seconds

return ( time_in_sec );// sends converted time to main to be processed
return 0;
}

8. Just to elaborate on what Salem said:

You can't define a function inside another function. Your structure should look like this:

Code:
```int my_function(int number)
{
....
....
}

int main()
{
.....
int result = my_function(3);
.....
return 0;
}```

<< !! Posting Code? Read this First !! >>

9. I hate to be such a pain. I have tried the suggestions made and my program compiles but when it is executed it will have: Please enter a start time <HH:MM:SS> -->(I enter the start time)
then the same line is repeated but asks for the end time-->Press any key to continue. All this is on the same line for the end time. When I press a key the program exits. Any suggestions.

#include <iostream>
#define SecondsPerHour 3600
#define SecondsPerMinute 60
#define MinutesPerHour 60

int Time_in_Seconds( int hh, int mm, int ss)
{
int time_in_sec;

time_in_sec = (hh * SecondsPerHour) +
(mm * SecondsPerMinute)+(ss);// converts standard time into seconds

return ( time_in_sec );// sends converted time to main to be processed

}
int main ()
{
int hh, // hours
mm, // minutes
ss, // seconds

begin_sec, end_sec, // times converted
sec_elapsed; // difference between times

printf( "Please enter a start time (HH:MM:SS) --> " );// read start time
scanf ( "%d%d%d", &hh, &mm, &ss);

begin_sec = Time_in_Seconds(hh,mm,ss); // converts the start time to seconds by calling on function

printf( "Please enter an end time (HH:MM:SS) --> " );// read end time
scanf ( "%d%d%d", &hh, &mm, &ss);

end_sec = Time_in_Seconds(hh, mm, ss);// calls on function that will convert entered time to seconds

sec_elapsed = end_sec - begin_sec; // calculates the time difference

return 0;
}

10. The '\n' character will print a new line.

11. Where do I need to put this at

12. Just put it in the printf wherever you want the newline to start. i.e.

printf("The next line will be on a new line.\nThis is on a new line.");

13. then the same line is repeated but asks for the end time-->Press any key to continue. All this is on the same line for the end time. When I press a key the program exits.
What do you expect your program to do? You ask the user for two pieces of information, you perform some calculations, and then your program ends(that's what the "Press any key to continue" message means). If you want your program to do something else, then you have to program it to do something else.

I'm guessing you want to ouput some information based on what the user entered, but you don't have any lines of code that output any information to the screen after you read in the input from the user. Computers are dumb, they can't read your mind and decide what to output for you.