int main()
{
FILE *fs,*ft;
char ch;
fs=fopen("main.c","r");
if(fs==NULL)
{
printf("can not open source file\n");
getch();
exit(1);
}
ft=fopen("demo.docx","w");
if(ft==NULL)
{
printf("can not open target file\n");
getch();
exit(1);
}
while(1)
{
ch=fgetc(fs);
if(ch==EOF)
{
break;
}
fputc(ch,ft);
}
fclose(fs);
fclose(ft);
return 0;
}
使用上面的代码,我试图将main.c
的内容复制到demo.docx
。
程序工作正常,但当我在外部打开demo.docx
时,它崩溃了。
从我这边来看是否有问题,或者我们无法使用c写入docx
文件?我们可以用c写一个word文件吗?
是的,你可以。但是,您是否详细研究了[docx](http://en.wikipedia.org/wiki/Docx)文件格式(您需要数月或数年的工作)? –
@BasileStarynkevitch:请给我一个结论 – zee
这是一个想法。法文和英文字母相同(差不多)。那么英语单词在法语中的意思是否相同? –