C/C++の宿題を片付けます 117代目 at TECH
[2ch|▼Menu]
405:デフォルトの名無しさん
08/11/08 04:29:47
>>402
#include <stdio.h>
#include <string.h>
int main()
{
 char str[100], needle[50], *p;
 int i = 0;
 printf("検索対象文字列を入力:");
 scanf("%s", str);
 printf("検索文字列を入力:");
 scanf("%s", needle);
 printf("検索対象文字列→%s\n", str);
 printf("検索文字列→%s\n", needle);
 printf("検索結果\n%s\n", str);
 p = str;
 while(strstr(p, needle) != NULL){
  if(p == strstr(p, needle)){
   i++;
   printf("*");
  } else
   printf(" ");
  p++;
 }
 printf("\n%d個発見しました\n", i);
 return 0;
}


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4985日前に更新/337 KB
担当:undef