#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int fun(char *s, char *t)
{ int n;
char *p, *r;
n = 0;
while(*s){p = s;
r = t;
while(*r)
if(*r == *p)
{
r++; p++;
} elsebreak;
if(r == '\0')n++;
s++;}
return n;
}main( )
{ char s[100], t[100];
int m;
system("cls");
printf("\nPlease enter string S:" );
scanf("%s", s);
printf("\nPlease enter substring t:");
scanf("%s", t);
m = fun(s, t);
printf("\nThe result is : m = %d\n", m);}
这里连在一起了
给你改好了
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int fun(char *s, char *t)
{ int n;
char *p, *r;
n = 0;
while(*s){p = s;
r = t;
while(*r)
if(*r == *p)
{
r++; p++;
} else
break;
if(r == '\0')n++;
s++;}
return n;
}main( )
{ char s[100], t[100];
int m;
system("cls");
printf("\nPlease enter string S:" );
scanf("%s", s);
printf("\nPlease enter substring t:");
scanf("%s", t);
m = fun(s, t);
printf("\nThe result is : m = %d\n", m);}