function()
{
FILE *ptr;
ptr = fileopen(file1.txt)
fprint(ptr, some text) //print to file 1
if(second file needed)
{
ptr = fileopen(file2.txt) //open a second file, assign to same file pointer
fprint(ptr, some text) //print to file 2 not working here?
}
}
編輯:
不打印到第二個文件。不過,fprint()不返回負值。我可以爲第二個文件分配相同的文件指針嗎?
請在提問有關C++的問題時使用C++代碼,而不是僞代碼。 – 2010-07-09 01:13:00
好的,對不起。 – 2010-07-09 01:14:19
當然有人問你爲什麼要使用C I/O機制,而不是更強大和方便的C++ iostreams。 – 2010-07-09 01:16:48