Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

PPCThug

a realy stupid question, how do I put char constants in my code?

This topic is 5950 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

a dumb question I know but I can''t figure it out. example if ( quit == y )break;
MSVC++ 6.0 intro DX 8.0a DX SDK 6.1 win98 #define WIN32_LEAN_AND_MEAN the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.

Share this post


Link to post
Share on other sites
Advertisement


C#
private const int NUM_OF_STUDENTS = 400;

C++

#define NUM_OF_STUDENTS 400

OR

const int NUM_OF_STUDENTS = 400;

For your example though, I would make Quit a boolean.

if(quit) // where quit is an int of 1 or 0
{
// exit;
}


"Wisdom is proportionate to your reference base. Intelligence is the ability to appropriately use that Wisdom."

Share this post


Link to post
Share on other sites
err.... not sure what Leatherwulfe is talking about, but char constants are like this: ''y''



Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
Character constants must be denoted by apostrophes (single quotes), as such: if(quit == ''y''). (With strings, of course, we use conventional double quotes, so ''y'' is a character, while "y" is a string.)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If (StrCompare(quit, "Y" != 0)
//They were equale
else
//They were not

I''m pretty sure its StrCompare, it might be StrCmpr. Hope that helps, good luck.

Share this post


Link to post
Share on other sites
Whoops, I totally misread his post. Nevermind me

"Wisdom is proportionate to your reference base. Intelligence is the ability to appropriately use that Wisdom."

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
strcmp

Share this post


Link to post
Share on other sites
hehe, at least you aren''t suggesting strcmp like all those AP''s



Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
hehe true.


I would do this though, assuming quit is a char:

if(tolower(quit) == 'y')
{
break;
}

That way you are covered if quit = 'y' or 'Y'




"Wisdom is proportionate to your reference base. Intelligence is the ability to appropriately use that Wisdom."


[edited by - Leathrewulfe on August 27, 2002 7:06:22 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!