Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
At school I use Visual Studio.

And there's a function there called 'stricmp' which compares two strings insenstive to case.

While I could make a temp char array, and lower case both paramters, I don't really want to have to do that.

So is there a equivalent in Xcode? I tried using stricmp but Xcode told me it wasn't declared. :(
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
At school I use Visual Studio.

And there's a function there called 'stricmp' which compares two strings insenstive to case.

While I could make a temp char array, and lower case both paramters, I don't really want to have to do that.

So is there a equivalent in Xcode? I tried using stricmp but Xcode told me it wasn't declared. :(

stricmp is not a Standard C function, so you'd have to write it yourself.

Why would you make a copy? Compare characters until you find one that is different or you find the '\0' at the end. If you have different characters, convert both characters to lowercase and compare again.

Now for advanced programmers: Both strcmp and stricmp do a very simplistic way of string comparisons that gives completely unacceptable results in real life. Just have a look how iTunes sorts your albums: Very much different from what strcmp would do. For example, using strcmp or stricmp the numbers from 1 to 20 would be sorted in the order 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 3, 4, 5, 6, 7, 8, 9; iTunes gets that right. MacOS X provides a number of different ways to sort strings in the correct way, depending on your application.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.