源程序:
#include <stdio.h>
#include <string.h>
int main()
{
char s1[32], s2[32];
printf("Please in put s1[32]:\n");
scanf("%s", s1);
printf("Please in put s2[32]:\n");
scanf("%s", s2);
char *p1 = s1, *p2 = s2;
int count = 0;
int lengh = strlen(s2);
while (*p2 != '\0')
{
while (*p1 != *p2 && *p1 != '\0')
{
p1++;
}
if (*p1 == '\0')
{
printf("NO and EXIT!\n");
return 0;
}
else
{
count++;
p2++;
}
}
if (count == lengh)
{
printf("YES!\n");
}
else
{
printf("NO!\n");
}
return 0;
}
运行结果截图: