我这里有这段代码
#include <stdio.h>
#include <string.h>
#include<conio.h>
void main()
{
char s[] = "All work and no play makes Jack a dull boy.";
char word[10],rpwrd[10],str[10][10];
int i=0,j=0,k=0,w,p;
printf("All work and no play makes Jack a dull boy.\n");
printf("\nENTER WHICH WORD IS TO BE REPLACED\n");
scanf("%s",word);
printf("\nENTER BY WHICH WORD THE %s IS TO BE REPLACED\n",word);
scanf("%s",rpwrd);
p=strlen(s);
for (k=0; k<p; k++)
{
if (s[k]!=' ')
{
str[i][j] = s[k];
j++;
}
else
{
str[i][j]='\0';
j=0; i++;
}
}
str[i][j]='\0';
w=i;
for (i=0; i<=w; i++)
{
if(strcmp(str[i],word)==0)
strcpy(str[i],rpwrd);
printf("%s ",str[i]);
}
getch();
}
我怎样才能替换“杰克”这个词?喜欢
输出:
All work and no play makes Jack a dull boy.
Enter ther word Jack to be Replaced
Mark
Tom
All work and no play makes Mark a dull boy.
All work and no play makes Tom a dull boy.
无需搜索整个句子。
谢谢