آموزش ++C آموزش و سورس های برنامه نویسی به زبان ++C |
||||||||||||||||||||||||||||||||||||
دو شنبه 4 ارديبهشت 1391برچسب:, :: 21:18 :: نويسنده : کیوان مجنونی
برنامه ای که نحوه عملکرد دو تابع strncmp و _strnicmp (در کامپایلر های بورلند: strnicmp) را نشان میدهد.
#include
#include void main(void) { char string1[]="The quick brown dog jumps over the lazy fox"; char string2[]="The QUICK brown fox jumps over the lazy dog"; char tmp[20]; int result; cout<<"Compare strings:\n\t\tString1= "< result = strncmp( string1, string2 , 10 ); if( result > 0 ) strcpy( tmp, "greater than" ); else if( result < 0 ) strcpy( tmp, "less than" ); else strcpy( tmp, "equal to" ); cout<<"Result:\t\tString 1 is "< result = strnicmp( string1, string2, 10 ); if( result > 0 ) strcpy( tmp, "greater than" ); else if( result < 0 ) strcpy( tmp, "less than" ); else strcpy( tmp, "equal to" ); cout<<"\nResult:\t\tString 1 is "< //end
نظرات شما عزیزان:
آخرین مطالب آرشيو وبلاگ پیوندهای روزانه پيوندها
![]() نويسندگان
|
||||||||||||||||||||||||||||||||||||
![]() |