Anyone know where I can get that?
I need the strncasecmp() function to compare two strings regardless of their case.
I can't find it anywhere, and it doesn't come with my compiler im using.
Anyone know where I can get that?
I need the strncasecmp() function to compare two strings regardless of their case.
I can't find it anywhere, and it doesn't come with my compiler im using.
try stricmp() or strnicmp(). I'm willing to bet you have those functions.
FAQ > How do I... (Level 1) > Where can I download a missing header file?
<string.h> is a standard header, not <strings.h>, but strcasecmp is not a standard function. Writing your own is fairly easy. [edit]Take a stab at it before peeking at this.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
I don't have either of those functions.
Im using strncmp() but I need something that will say the strings are the same if for example:
1) This Is A String
2) this is a string
I need both of those to be compared and the function to return that they are the same. Right now the strncmp() does not do this.
I only have the <string.h> header file, but in the <strings.h> file there is the strncasecmp(), in which I need.
What compiler are you using?
The linux gcc compilers in our computer labs have this header file, but my windows compiler does not have this, and I cannot get to the lab to grab it.
I'm just using a compiler I grabbed off a site called PellesC.
As, Dave said. It's easy to write your own. Look into <ctype.h> and the toupper() function. You don't go fishing around for nonstandard libraries when it's easy enough to write the code using standard libraries.
Sent from my iPadŽ
Doesn't using non-standard headers defeat the whole purpose of writing portable C code (which made C famous in the first place)?
I'm sort of a beginner at this but wouldn't stricmp() work?
I'm also wondering...Originally Posted by bigggame
Code:#include <stdio.h> void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){ puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9 /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i] ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][ t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}
Plese try to compile the following code and place error messages you're getting:
Code:#include <stdio.h> #include <string.h> int main (void) { char str1[] = "Test"; char str2[] = "test"; printf ("%d", stricmp (str1,str2)); return 0; }
Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem
Originally Posted by bigggameBeginner at reading, I guess. He already said.Originally Posted by JafetHow he doesn't, I don't know, but regardless, it's simple enough to write one.Originally Posted by Sev3r
Sent from my iPadŽ
Originally Posted by cdalten
If portability is a requiement, yes.
If it is not a requirement, or not particularly cared about, then no.
Mr. Blonde: You ever listen to K-Billy's "Super Sounds of the Seventies" weekend? It's my personal favorite.
Try _strnicmp() for MS compilers.I don't have either of those functions.
The best solution is to write your own string comparison function.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.