可以,如下:

int i = 56789

CString str

str.Format(_T("%d"),i)

file.Write(str.GetBuffer(),str.GetLength())

str.ReleaseBuffer()

file.Close()int类型变量,直接写入文件,是16进制格式,占4个byte(char)大小。

要想将int写入文本文件并直观可见,需要先转换为字符串,再写入文件。