#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
char sentence[100], str[100],read[50];
gets(sentence);//输入文件名;
gets(str);//输入字符串;
FILE* fp=fopen("b.txt","w");
if (fp == NULL)
{
perror("fopen");
return 1;
}
fprintf(fp, "%s", sentence);//将输入的字符文件打印到fp中;
int i = 0, j = 0, sz = strlen(str), SZ=strlen(sentence);
for (i = 0; i< SZ ; i++)//外层循环次数
{
for (j = i; j < sz + i; j++)//内层循环
{
*(read + j - i) = *(sentence + j);//将sentence+j之后的sz个字符依次赋给read;
*(read + j - i) = tolower(*(read + j - i));//将读到的所有字符转换成小写
}
*(read + j - i) = '\0';
//将每次读到的字符串转换为小写;
if (strcmp(read,str) == 0)
{
for (j = 0; j < sz; j++)
{
*(read+j) = toupper(*(read+j));//将所有字符转换成大写
*(sentence + i+j) = *(read+j);
}
}
}
puts(sentence);
fclose(fp);
fp = NULL;
return 0;
}