将十进制数写入文件
#include <stdio.h>#include <windows.h>
void strrindex(char a[],char b[])
{
int i,j;
char k[1];
for(i=10;a[i]!='\0';i++)
{
int n=10;
for(j=0;b[j]!='\0';j++)
{
if(a[i]!=b[j]) break;
i++;
n++;
}
if(b[j]=='\0')
{
k[0]=i-n+1;
printf("%d\n",k[0]);
FILE *fw;
fw=fopen("virusout.txt","w");
fputs(k,fw);
fputs("\n",fw);
break;
}
}
}
void dely()
{
int i;
for(i=3;i>=0;i--)
{
printf("倒计时:");
printf(" %d\n",i);
Sleep(5*400);//这里修改延时时间
}
}
void main()
{
printf("\n/************************题目:病毒查找************************/\n");
printf("It's opening the infected file , please wait......\n");
/*Sleep(5*1000);*/
char str[5000],str2[]="Languages";
FILE *fp;
char ch;
int i;
fp=fopen("virusin.txt","r");
if(fp)
{
int i=0;
int ch=0;
while(!feof(fp))
{
ch=fgetc(fp);
if(ch==EOF)
break;
str[i]=ch;
i++;
}
str[i]=0;
fclose(fp);
}
puts(str);
printf("******************************************************************************\n\n");
strrindex(str,str2);
}
怎么样把k的值写入txt文件中