Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » amateur: comparing strings

Credits go to miran for helping out!
This thread is locked; no one can reply to it. rss feed Print
amateur: comparing strings
Pavel Hilser
Member #5,788
April 2005
avatar

Sorry for this question. I was googling a lot, but have not found anything relevant :-/.
I have to compare two strings, if they are exact the same, but I have almost none experiences with strings in C. :(

_____________________________________
Mein Cannon - see my new 2d game

miran
Member #2,407
June 2002

--
sig used to be here

Pavel Hilser
Member #5,788
April 2005
avatar

ok, stupid me, thanx for kicking in the right direction :)

_____________________________________
Mein Cannon - see my new 2d game

Goalie Ca
Member #2,579
July 2002
avatar

-------------
Bah weep granah weep nini bong!

James Stanley
Member #7,275
May 2006
avatar

Forgive me, but what's wrong with '=='?

Paul whoknows
Member #5,081
September 2004
avatar

Quote:

Forgive me, but what's wrong with '=='?

You can't compare two strings using the "==" operator in C.Because in C a strings is an array of chars, so you have to compara each char in the array one by one.You can implement your own function to do that using a pointer to char, or you can use the ANSI C strcmp and stricmp functions.

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Go to: