|

楼主 |
发表于 2017-6-8 20:55:22
|
显示全部楼层
- #include <stdio.h>
- void main()
- {
- char str[40];
- int cmp( char *str1, char *str2 );
- printf("Please enter the website you like the best : ");
- scanf("%s", str);
- #ifndef CORRECT
- #define CORRECT "fishc.com"
- #endif
- if( cmp( str, CORRECT ) == 0 )
- {
- printf("\nYeah! You are a smart man!\n\n");
- }
- else
- {
- printf("\nYou fool! Man!!\n\n");
- }
- }
- int cmp( char *str1, char *str2 )
- {
- int i = 0, j = 0;
- while( str1[i] )
- {
- while( str2[j] == str1[i] )
- {
- i++;
- j++;
- if( !str2[j] )
- {
- return 0;
- }
- }
- j = 0;
- i++;
- }
- return -1;
- }
复制代码
这是完整的代码
这里的STR 和STR1 STR2是什么关系 |
|