|
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Wed Sep 10, 2008 11:55 pm Post subject: strcmpi failing? |
|
|
|
|
on mervbot ive got a comparison:
char offenders[20]={'C','h','e','e','s','e','\0'};
if(strcmpi(offenders,m_name)||1)
{
//stuff
}
i had to add the or 1 temporarily, because i couldnt get it to succeed any way i tried.
i also tried
char offenders[20]="Cheese"
char offenders[20]="cheese"
and a whole bunch of other crap.
this uses one of the outputs of my unpacker, which is:
char m_name[20]
i cant get this to work, any ideas?
-edit-
also, tiny extra:
whats the way to have a single character, buf=='/'
i know it wont accept it, it has to be '//' or '\/' or '\\/' or some other crap...
because of the line break / in the compiler.
-edit2-
and before i forget, sscanf seems to be failing too... =/
isnt %d for a signed int?
every time i send it a negative number, it fails...
signed int temp6 = 0;
sscanf(c->final, "%d", &temp6); _________________ SSC Distension Owner
SSCU Trench Wars Developer |
|
Back to top |
|
|
k0zy Server Help Squatter
Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
Posted: Thu Sep 11, 2008 1:11 am Post subject: |
|
|
|
|
stcmpi returns 0 if the two strings are identical.
0 equals false, so if you want something to happen if the two strings are equal you have to do:
if (!strcmpi(x,y))
or
if (strcmpi(x,y) == 0) _________________ It's a shark! Oh my god! Unbelievable! |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Sep 11, 2008 6:35 am Post subject: |
|
|
|
|
==0 is the preferred syntax. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Thu Sep 11, 2008 4:16 pm Post subject: |
|
|
|
|
aargh, nonzero is supposed to be true =(
thanks =P |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Thu Sep 11, 2008 5:01 pm Post subject: |
|
|
|
|
nonzero is true, but strcmp (and related functions) don't return true or false
They return the difference between the two strings; so 0 means no difference. You can use it to sort strings; if it returns positive, it means one of the string is 'higher', alphabetically-speaking than the other, and a negative return value would mean the opposite. _________________ (Insert a bunch of dead links here) |
|
Back to top |
|
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 1192 page(s) served in previous 5 minutes.
|