Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » It don't mean a thing, if you aint got that string! (C++ help needed)
It don't mean a thing, if you aint got that string! [message #421101] Sun, 28 February 2010 06:23 Go to previous message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma:
General (3 Stars)
I have a std::string (oh noes, not std!). And I want to tell if the first character in that string is an ampersand (&).
The std::String variable is strd.

This conditional returns true always, even if the first character is not an ampersand:

if(strd[0] == '&'){


So I thought I'd try this:

const char *character = (const char *)strd.at(0);
printf("%s\n",strd.c_str());
printf("%c\n",strd[0]);
printf("%c\n",character);
if(strstr(character, "~")){


The printf's print the following:

Quote:


#lobby
#
#



Then at the strstr it crashes (I guess because it's supposed to be comparing strings, not characters).

Can someone suggest an appropriate way to check if the first character of a std::string equal &, please?



 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: XCC Mixer?
Next Topic: Waterfall problems
Goto Forum:
  


Current Time: Mon Dec 30 05:09:06 MST 2024

Total time taken to generate the page: 0.00766 seconds