| | |
Help:What would happen when the code is run?
![]() |
•
•
Join Date: Sep 2007
Posts: 12
Reputation:
Solved Threads: 0
What would happen when the code is run?
a) As originally written?
b) With the first bug fixed?
1: unsigned long normalise(unsigned long input_time)
2: {
3:
4: bool finished;
5:
6: // This produces a formatted time string like:
7: // Thu_Nov_24_18:22:48_1986
8: string str_time = format_time( input_time );
9:
10: while( str_time.substr(1,3) != "Sun")
11: {
12: input_time -= 24*60*60;
13: str_time = format_time( input_time );
14: }
15:
16: while( str_time.substr(11,2) != "00" )
17: {
18: input_time -= 60*60;
19: str_time = format_time( input_time );
20: }
21:
22: while( str_time.substr(14,2) != "00")
23: {
24: str_time = format_time( input_time );
25: input_time -= 60;
26: }
27:
28: while( str_time.substr(17,2) != "00")
29: {
30: input_time -= 1;
31: str_time = format_time( input_time );
32: }
33:
34: return input_time;
35: }
a) As originally written?
b) With the first bug fixed?
1: unsigned long normalise(unsigned long input_time)
2: {
3:
4: bool finished;
5:
6: // This produces a formatted time string like:
7: // Thu_Nov_24_18:22:48_1986
8: string str_time = format_time( input_time );
9:
10: while( str_time.substr(1,3) != "Sun")
11: {
12: input_time -= 24*60*60;
13: str_time = format_time( input_time );
14: }
15:
16: while( str_time.substr(11,2) != "00" )
17: {
18: input_time -= 60*60;
19: str_time = format_time( input_time );
20: }
21:
22: while( str_time.substr(14,2) != "00")
23: {
24: str_time = format_time( input_time );
25: input_time -= 60;
26: }
27:
28: while( str_time.substr(17,2) != "00")
29: {
30: input_time -= 1;
31: str_time = format_time( input_time );
32: }
33:
34: return input_time;
35: }
If the code you posted contains errors then nothing will happen because the compiler will not generate an executable program. The ocmpiler generates the final executable program only when you have fixed all errors.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Sudoku Source Code (C++)
- How to run external .exe programs from java (Java)
- URGENT Help Needed With TicTacToe Application Source Code!!! (Java)
- URGENT: Need help on I/O code! (Java)
- Need help with Quiz code (Java)
- High-Level Languages (Computer Science)
- Populating & Retrieving Data in a listbox : ASP.NET (w/ VB.NET) (ASP.NET)
- help!! My applet can't run... Urgent!! (Java)
- Some Basic Code Hopefully (Help Needed) (HTML and CSS)
Other Threads in the C++ Forum
- Previous Thread: help needed
- Next Thread: help needed
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ char class classes code coding compaitibility compile console conversion count delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error factorial file floatingpoint forms fstream function functions game givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker loop looping loops map math matrix memory multiple net news node number numbertoword output parameter payment pointer problem program programming project projectassignmenthelp protection python random rank read recursion reference rpg skills string strings temperature template test text text-file tree url variable vector video win32 windows winsock word wordfrequency wxwidgets






