LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   need some advices, which way is better (http://www.linuxquestions.org/questions/programming-9/need-some-advices-which-way-is-better-260044/)

foxele 11-28-2004 12:25 AM

need some advices, which way is better
 
Hello:

I am writting a strIgnoreCaseCmp module which performs the same basic function as strncmp() but ignore case when comparing two strings.



The function prototype is int strIgnoreCaseCmp(const char *s1,
const char *s2,
unsigned int n)


for the compare part, I can just call strncmp(), but for the ignoring case part, I am not sure if I should use strlwr in string.h, or I have to use strlen combine with tolower to change the case of each character in the string.

I didn't use strlwr before, do you think it is a better way?


Thanks!


Alex

vharishankar 11-28-2004 01:24 AM

There is already a built in function for comparing cases insensitve. Just check up the

strcasecmp
strncasecmp

function in the man page. Both declared in strings.h

foxele 11-28-2004 04:30 PM

sorry I didn't tell you, I am not allowed to use it.

jlliagre 11-29-2004 12:36 AM

Sorry, I'm not allowed to provide an answer to you ....

vharishankar 11-29-2004 12:42 AM

Quote:

Originally posted by foxele
sorry I didn't tell you, I am not allowed to use it.
Sound very much like your homework problem.
Did you read the rules: http://www.linuxquestions.org/rules.php


All times are GMT -5. The time now is 08:56 AM.