#include <conio.h>
#include <stdio.h>
#include <string.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;
clrscr( );
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);}
将clrscr();替换成 system("cls");再加#include<stdlib.h>头文件。
你调用方法,但是你方法定义在哪呢?
clrscr( ); 没有定义。这个应该是TC提供的清屏函数。
可以改用system("cls");
clrscr( );
没有这个函数