c語言fwrite 換行

#include <stdio.h> int main() { FILE *pFile=NULL; int a=123; int b=456; int c=789; char *info=new char[4]; pFile=fopen("test.txt","ab+"); if (pFile) { //寫入a sprintf(info,"%d",a); fwrite(info,1,3,pFile); ////換行 fwrite("\r\n",1,2,pFile);//注意此處 count=2 //寫入b sprintf(info,"%d",b); fwrite(info,1,3,pFile); //換行 fwrite("\r\n",1,2,pFile); //寫入C sprintf(info,"%d",c); fwrite(info,1,3,pFile); } fclose(pFile); delete [] info; return 0; }it

相關文章
相關標籤/搜索