Variables within strings? (C++)

Started by
22 comments, last by ifthen 11 years, 4 months ago
Ah, thanks. That solved the problem.
But now it's saying I have to return a value...
error C4716: 'wait' : must return a value
Advertisement
It's telling you the problem. You declared your function to return an int, so the compiler is telling you that you aren't doing that. If you don't want the function to return a value then change the function to return void.
int wait(int x)
{
Sleep(1000 * x);
return (x);
}


Code fixed by doing this, just in case someone happens to be reading this in the future.
SiCrane described your problem. The correct version is
[source lang="cpp"]void wait(int x)
{
Sleep(1000 * x);
}[/source]
By writing "int" in front of your function, you are saying that it will return an integer. But why should you return an integer in a wait function? If you write "void" instead, you are saying that the function does not return anything.
Solve your problems by thinking about them, not by strafing around them.

This topic is closed to new replies.

Advertisement