• Advertisement
Sign in to follow this  

char Check

This topic is 4622 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

Is there an easy way to check what a string says? For example: if(Text == "Bill got hit by a truck"){KillBill();} It seemed like it work compile on its own. [Edited by - AntiGuy on May 29, 2005 6:12:44 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sorry didn't do it on purpose. You can probably tell by the 1 second time span between creation.

Share this post


Link to post
Share on other sites
If Text is defined as:
std::string Text;

What you have will work

If it's defined as:
char* Text;

You will have to use
if( strcmp(Text,"Bill got hit by a truck") == 0 )

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Oberon_Command
Nope, can't see the difference that fast. It's not a chatroom...


Look at the time stamp, it uses seconds.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Quote:
Original post by Oberon_Command
Nope, can't see the difference that fast. It's not a chatroom...


Look at the time stamp, it uses seconds.


I meant actually seeing...

Oh, never mind. [grin]

Share this post


Link to post
Share on other sites
Quote:
Original post by AntiGuy
It seemed like it work compile on its own.


The reason it compiles is because "Bill got hit by a truck" has an actual address in the data segment of your program. What you have will compare this value with the value of Text (the number of the memory location it points to). This is certainly not what you want though...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement