欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
fgets(); strlen(); strstr();綜合應用
[打印本頁]
作者:
liumei
時間:
2014-4-10 14:27
標題:
fgets(); strlen(); strstr();綜合應用
#include <stdio.h>
#include <string.h>
#include <ctype.h> /* fgets() strlen() strstr() */
fgets() strlen() strstr()
int i,j;
int main()
{
char str1[100];
char str2[40];
printf("\nEnter the string to be searched (less than 100 characters):\n");
fgets(str1, sizeof(str1), stdin);
printf("\nEnter the string sought(less than 40 characters):\n");
fgets(str2, sizeof(str2), stdin);
/* overwrite the newline character in each string *///overwrite: 重寫
str1[strlen(str1) - 1] = '\0'; //用\0取代回車,構成新數組(字符串)
str2[strlen(str2) - 1] = '\0';
printf("\nFirst sting entered:\n%s\n", str1);
printf("\nSecond sting entered:\n%s\n", str2);
/* Convert both strings to uppercase *///uppercase: n. 大寫字母
for(i = 0; (str1[i] = toupper(str1[i])); i++);
for(j = 0; (str2[j] = toupper(str2[j])); j++);
printf("\nThe second string %s found in the first",((strstr(str1,str2)==NULL)?"was not":"was"));
return 0;
}
psb(87).png
(27.57 KB, 下載次數: 231)
下載附件
2014-4-10 14:27 上傳
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1