| R2B Boondocks (6) | |||||
|
I am supposed to develop a program that takes a song title and its playtime from a user in the form of H:MM:SS Song Title. It should print right below it: Song Title Playtime (except playtime is rolled over [i.e 0 0 127 would become 0 02 07]). I will post a before and after code. The before functions as it should, just looks sloppy. The after code is my attempt at making it look better. I failed lol. I could use some help ASAP please. Thanks. Before Code:
After Code:
| |||||
|
|
|||||
| Framework (3116) | |||||
This is not a function invocation (call). This is in fact a declaration of a variable, called "add", which is initialised with the value of "totalSecs." Remove "int", and the equals symbol, and you'll be good to go. Do this for all function calls that appear in this way. Wazzak | |||||
|
|
|||||
| R2B Boondocks (6) | |||||||
I changed them to:
I now get these errors: In function 'int main()': error: 'add' was not declared in this scope error: expected primary-expression before 'int' error: expected primary-expression before 'int' error: expected primary-expression before 'int' error: 'normalize' was not declared in this scope error: expected primary-expression before 'char' error: expected primary-expression before 'char' error: expected primary-expression before 'char' error: 'twoDigits' was not declared in this scope error: expected primary-expression before 'int' error: expected primary-expression before 'int' error: expected primary-expression before 'int' error: 'printTime' was not declared in this scope My proposed solution: instead of
Do
So that they are "declared in this scope". Thoughts? EDIT** This did not work :/ | |||||||
|
Last edited on
|
|||||||
| ToniAz (341) | |||||
|
I mean, the errors are self-explanatory, don't you think? Did you go over a tutorial of C++, or you saw some code sitting there and went on to compile it? I don't mean to sound rude, here are the error explanations:
add is not declared in main() before it is used. Moreover, I honestly cannot tell what add is. At one point you're using it as a function, and at another point as a parameter!
You're writing a prototype for the function normalize() inside main()!
You're writing a prototype for the function twoDigits() inside main()!
You're writing a prototype for the function printTime() inside main()! Kindly go over this small introduction to functions http://www.cplusplus.com/doc/tutorial/functions/ | |||||
|
Last edited on
|
|||||
| R2B Boondocks (6) | |
|
Self explanatory yes to an individual who has a sense of what they're doing. Much like a wiring schematic for a vehicle remote start being easily read to me since that is what I do. I will be honest with you. I do not know what I am doing in C++ so I took no offense from your statements. I will review your link and see if I can't figure this out. Thank you. | |
|
|
|
| R2B Boondocks (6) | |||
|
I believe I have conquered the function issue :). Thank you all for the help. I'd like to ask one last question though. The code runs fine and works perfectly up until I signify end of user input (ctrl-z). It then spits out the total song times. It works in the sense that it keeps the remainders for seconds, minutes, etc. However, it does not add those increments of 60 over to the next value. For example: 0 61 0 Time // User sees this output// Time 1:01:00 0 59 Money // User sees this output //Money 0 59:00 ctrl-z //signifying end of user input Total: 1:00:00 The hours should read 2 here. I'm sure it is something simple. Here is my code.
Thank you | |||
|
|
|||