Help with stricmp outputs

i was wondering how the outputs worked for stricmp in otherwords how you could calculate what the out put would be for example i found this

1
2
3
4
5
    printf( "%d\n", stricmp( "AbCDEF", "abcdef" ) );
    printf( "%d\n", stricmp( "abcdef", "ABC"    ) );
    printf( "%d\n", stricmp( "abc",    "ABCdef" ) );
    printf( "%d\n", stricmp( "Abcdef", "mnopqr" ) );
    printf( "%d\n", stricmp( "Mnopqr", "abcdef" ) );


the outputs would be:
1
2
3
4
5
0
100
-100
-12
12


i understand if they are equal then its 0 but how do i know the output if i were to compare them so i could do this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
          char *Name1 = "Ryan";
		char *Key = "abc";

		if ((!_stricmp(Me->pPlayerData->szName, Name1) == TRUE))
		{
			Print(0, 4, "ÿc5Authentication:ÿc3 ---User: ÿc5Ryan---");
		}
		else if ((!_stricmp(Me->pPlayerData->szName, Name1) == FALSE))
		{
			Print(0, 4, "ÿc5Authentication:ÿc3 ---Failed---");
			ExitGame();
		}
		if ((!_stricmp(Key, TeamnzeroList100) == output???))
			Print(0, 4, "")
		else
			ExitGame();
	}

	return TRUE;
}


that way if someone were to hex edit the string of the name1 it would change the output value making it more difficult for just a regular with a hex editor

and another question stricmp isn't case sensitive what pointer would be identical to it but with case sensitivity?
Don't worry about the exact values. You just need to know about zero, less than zero and greater than zero.

Regarding your code:
 
if ((!_stricmp(Me->pPlayerData->szName, Name1) == TRUE))
Don't do that.

Either do:
 
if (_stricmp(Me->pPlayerData->szName, Name1) == 0)
or:
 
if (!_stricmp(Me->pPlayerData->szName, Name1)

The case sensitive C string compare function is strcmp().
Last edited on
If statements will resove with a zero and nonzero so you could just use

if (!stricmp(foo, foofoo)) // true in this case


If is returns less than 0, str1 is less then, if it returns greater than 0, str1 is greater. If you want that level of control you can compare if return to 0.

if (stricmp(foo, foofoo) > 0)

if (stricmp(foo, foofoo) < 0)


This is more suited for a C forum by the way.
Last edited on
thank you this is what i have now and its :S

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
char *Name1 = "Ryan";
		char *Key = "a";
		INT Output = -25;

		if ((!_stricmp(Me->pPlayerData->szName, Name1) == TRUE))
		{
			Print(0, 4, "ÿc5Authentication:ÿc3 ---User: ÿc5Ryan---");
		}
		if ((!_stricmp(Me->pPlayerData->szName, Name1) == FALSE))
		{
			Print(0, 4, "ÿc5Authentication:ÿc3 ---Failed---");
			ExitGame();
		}
		if ((_stricmp(Key, Name1) == Output))
		{
			Print(0, 4, "OutputCorrect");
		}
		if ((_stricmp(Key, Name1) == !Output))
		{
			Print(0, 4, "%d\n", _stricmp(Key, Name1));
			ExitGame();
		}
	}

	return TRUE;
}


now it use the last print() to figure out the output and then found it was -25
i tried to set the output to say if name = "ryan" and output = -25 then load if name = not "ryan" or output = !-25 then don't load this way someone would have to know the output value of the key, "their hexed name" in order for it to load since if you change it so does the output all works but one thing

if name = ryan it will load say everything and work itl print "Outputcorrect" but if i change the name to something like "erer" it will load and say all was well but it wont say if output is correct or leave game if it isn't im assuming something to do with my INT
ok i got it and it works now i realized i was trying to say opposite of output when i should have put a less than or greater than and it all works thank you forum for the help this is the first time i have really reached out for help on something other than doing it myself and well thank you :)
Topic archived. No new replies allowed.