Ecere SDK/eC Forums http://www.ecere.com/forums/ Print view |
|
登陆界面(login Interface) http://www.ecere.com/forums/viewtopic.php?f=30&t=37 |
Page 1 of 1 |
Author: | liqi98136 [ Wed Mar 10, 2010 8:12 am ] |
Post subject: | 登陆界面(login Interface) |
字符串的比较问题,有谁有更好的方法。 On comparison of string, who have a better way??? strcmp(str1,str2) str1 > str2 return >0 str1==str2 return 0 str1 < str2 return <0 当s1<s2时,返回值<0 当s1=s2时,返回值=0 当s1>s2时,返回值>0 能不能直接比较? How to directly compare? str3="abc" if(str3=="abc") { ...} Code: Select all
|
Author: | jerome [ Wed Mar 17, 2010 6:24 pm ] |
Post subject: | Re: 登陆界面(login Interface) |
Hi liqi, strcmp is quite standard in C/eC. I usually write it: if(!strcmp(str1, str2)) { PrintLn("Strings are the same!"); } Having a negative, zero, or positive value is very useful in sorting situations. eC also has an 'OnCompare' method accessible on all data types, including on 'String' (Which simply maps to 'char *' at the moment). You could invoke it as such; Code: Select all
Cheers, Jerome |
All times are UTC-05:00 | Page 1 of 1 |
Powered by phpBB® Forum Software © phpBB Limited |