功能:格式化輸出資料至檔案
/* fprintf example */
#include <stdio.h>
int main ()
{
FILE * pFile;
int n;
char name [100];
pFile = fopen ("myfile.txt","w");
for (n=0 ; n<3 ; n++)
{
puts ("please, enter a name: ");
gets (name);
fprintf (pFile, "Name %d [%-10.10s]\n",n,name);
}
fclose (pFile);
return 0;
}
參考出處::
http://www.cplusplus.com/reference/cstdio/fprintf/?kw=fprintf
沒有留言:
張貼留言