2014-08-29 663 views
0

我想更改之前創建的* .txt文件的大小。爲此,我使用chsize。 代碼:「FILE * {aka _iobuf}'無效轉換爲'int'」錯誤

#include <iostream> 
#include <stdio.h> 
#include <io.h> 

using namespace std; 

int main() 
{ 
    FILE *wfile; 
    wfile = fopen("test.exe", "a"); 
    chsize(wfile, 1024); //error is here 
    file.close(); 
    return 0; 
} 

這裏而來的錯誤:

[Error] invalid conversion from 'FILE* {aka _iobuf*}' to 'int' [-fpermissive]

問:這裏有什麼問題?我打開文件fopen正確的是如何在互聯網中解釋。

Q2:我喜歡Windows作爲操作系統,但我不想學習Windows API for C++或類似的東西。有沒有選擇使用便攜式的東西?

+0

chsize()對文件描述符采用整數。您無法將「FILE *」轉換爲 - http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.neutrino.lib_ref%2Ftopic%2Fc %2Fchsize.html – 0x499602D2 2014-08-29 15:32:54

+0

'file.close();'也不好,應該是'fclose(wfile);' – 2014-08-29 15:33:13

+0

** A2 **到** Q2 **:使用'' – 2014-08-29 15:34:56

回答

相關問題