2014-08-29 662 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

回答

相关问题