What do you mean by "it doesn't work". Compile error, linker error, runtime error?
You have forgot put a return statement in the welcome() function.
Thanks, but I don't want to put the return. How can I do that?
In Codeblocks there is no need to add return 0;
If you turn on more warnings you will get a warning in Code::Blocks too.
|warning: no return statement in function returning non-void [-Wreturn-type]|
Here is what the standard says about leaving out the return statement.
|Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function.|
is something that you should always try to avoid. It means that there is no guarantees and anything can happen.
The main function is an exception. If you don't return anything from main() it will automatically return 0.
If you don't want welcome() to return anything you can change the return type to void and leave out the return statement. Now when I read what you wrote more carefully I think this is what you want.
Last edited on
Thanks guys, I got the answer.
exactly :) Thanks