Jump to content

View more

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Variables within strings? (C++)

4: Adsense

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   

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

#22 SiCrane   Moderators   

11762
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   

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   

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.