正文:
比如打開"myfile.txt"
1,在c中使用的傳統(tǒng)的<stdio.h>
FILE* fp;
char* fn = "myfile.txt";
fp = fopen(fn, "a+");
if( fp != NULL )
{
//use file
}
fclose(fp);
2, 在c++推薦使用的<fstream.h>
ofstream of;
of.open("myfile.txt")
of.close()
這個個人感覺比fopen好用,一般的使用不用關(guān)注那么多的參數(shù)。
3, 在Win32中使用的CreateFile函數(shù)。
在Windows上,感覺使用CreateFile系列函數(shù)比較正宗,得仔細(xì)看看 msdn, 每次寫一個(void*)的數(shù)據(jù)塊到文件,很通用。
4,在mfc中使用CFile
這個很少用。不清楚,可能很方便。本篇文章來源于:開發(fā)學(xué)院
http://edu.codepub.com 原文鏈接:
http://edu.codepub.com/2009/1021/16577.php