| MarcusFenix (10) | |||
|
Hi, I cant figure out on what is wrong with the code I have made. Anyone can help. I am getting error while compiling. 'ABC' undeclared(first use this function) 'buy' undeclared(first use this function) [Warning] the address of 'int TodaysDate()'. will always eevaluate as 'true'. What does this error means.
Thanks, Marcus | |||
|
|
|||
| HiteshVaghani1 (207) | |
| Declare ABC and buy and initialize them with some value... | |
|
|
|
| TheIdeasMan (1757) | |||
|
Some comments: Your TodaysDate function is supposed to return an int, but there is no return statement. With std::cout it looks as though it should have a return type of void, but then you call the function on line 41. Perhaps you should get it to return a std::string ? #include <string> if you want to use strings. Or you could just call the function first - like this to the same effect:
It is a good idea to declare you functions before main, and define them after main. If there are lots of functions, we don't have to scroll through all of them to see what main() does - main() may not call all of them. You can declare & initialise all in one go like this: float f = 20.0;So lines 18 to 24 & 27 to 39 could be combined together. With the ABC & buy - did you mean them to be "ABC" & "buy" - string literals as opposed to variables? The 01 on line 11 doesn't pre-pend a zero to the answer, a leading zero actually means the number is in octal format & 0x means hexadecimal. You could check if the value is less than 10, then use the std::string operator + to pre-pend the zero. Hope this helps ! Have fun :D | |||
|
Last edited on
|
|||
| MarcusFenix (10) | |
|
Hi TheIdeasMan, Appreciate your response. With regards to ABC & buy, yes I meant it to be "ABC" & "buy". Because sooner on the code I will be changing it to another strings! Once again appreciate all your responses. Thanks, Marcus | |
|
|
|