if(!strcmp(m_edit,"haha");
{
MessageBox("haha");
}
else
{
MessageBox("LOL");
}
is there anything wrong with this code???
how come my result is the "LOL" one even i enter the correct one
im using the VisualC++
if(!strcmp(m_edit,"haha");
{
MessageBox("haha");
}
else
{
MessageBox("LOL");
}
is there anything wrong with this code???
how come my result is the "LOL" one even i enter the correct one
im using the VisualC++
strcmp() is telling you that the two strings are not the same. Since one string is a literal, I would suggest you check the contents of the other, because it is clearly not what you think it is!
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
and strcmp() is case sensitive. so 'm_edit' must contain 'haha', not 'Haha' or 'HAHA' and so on...
Sometimes, the farthest point from the center is the center itself.
Your life is your canvas, it's only as beautiful as you paint it.
can i make it not case sensitive
Hey,
Yer you could convert the string to lowercase before you check it.(the one in the edit box).
Look into the function tolower() and use it before you do the strcmp.
Hope that helps.
TNT
TNT
You Can Stop Me, But You Cant Stop Us All
yes, use strcmpi().can i make it not case sensitive
Sometimes, the farthest point from the center is the center itself.
Your life is your canvas, it's only as beautiful as you paint it.
how to i use the strcmpi(); ????
or can i do like the word is Chris Sim
then i enter Chris only and it will return mi the result
Last edited by monkeymon; 04-08-2002 at 08:11 PM.
From MSDN...
Code:#include <string.h> #include <stdio.h> char string1[] = "The quick brown dog jumps over the lazy fox"; char string2[] = "The QUICK brown dog jumps over the lazy fox"; void main( void ) { char tmp[20]; int result; /* Case sensitive */ printf( "Compare strings:\n\t%s\n\t%s\n\n", string1, string2 ); result = strcmp( string1, string2 ); if( result > 0 ) strcpy( tmp, "greater than" ); else if( result < 0 ) strcpy( tmp, "less than" ); else strcpy( tmp, "equal to" ); printf( "\tstrcmp: String 1 is %s string 2\n", tmp ); /* Case insensitive (could use equivalent _stricmp) */ result = _stricmp( string1, string2 ); if( result > 0 ) strcpy( tmp, "greater than" ); else if( result < 0 ) strcpy( tmp, "less than" ); else strcpy( tmp, "equal to" ); printf( "\t_stricmp: String 1 is %s string 2\n", tmp ); } Output Compare strings: The quick brown dog jumps over the lazy fox The QUICK brown dog jumps over the lazy fox strcmp: String 1 is greater than string 2 _stricmp: String 1 is equal to string 2
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Adrian what are you doing!?!?!?
void main( void )
Watch out or you'll get an angry Prelude in the head
The important thing was his quote "From MSDN..."Originally posted by ErionD
Adrian what are you doing!?!?!?
Watch out or you'll get an angry Prelude in the head
Some of the code on MSDN is ancient.......
>>> Watch out or you'll get an angry Prelude in the head.
LOL. Fordy explained. I'll refer her to Bill!
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.