Jump to content

  • Log In with Google      Sign In   
  • Create Account

Variables within strings? (C++)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
23 replies to this topic

#21 Youbar   Members   -  Reputation: 122

Like
0Likes
Like

Posted 01 December 2012 - 04:51 PM

Ah, thanks. That solved the problem.
But now it's saying I have to return a value...
error C4716: 'wait' : must return a value

Sponsor:

#22 SiCrane   Moderators   -  Reputation: 9596

Like
1Likes
Like

Posted 01 December 2012 - 05:02 PM

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.

#23 Youbar   Members   -  Reputation: 122

Like
0Likes
Like

Posted 01 December 2012 - 05:11 PM

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.

#24 ifthen   Members   -  Reputation: 820

Like
0Likes
Like

Posted 01 December 2012 - 05:23 PM

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.

Edited by ifthen, 01 December 2012 - 05:24 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS