使用Eclipse中出现的一些问题的解决方法

错误提示: error: ‘EOF’ was not declared in this scope
解决方案:#include <cstdio>


错误提示:cannot open output file xxx.exe: Permission denied
解决方案: 出现这个错误,应该是之前写的程序有问题,上次编译执行后没有完全退出导致的。打开任务管理器,杀死所有xxx.exe进程即可。(转自 http://www.pocketdigi.com/20110711/376.html


错误提示:error: 'exit' was not declared in this scope;
解决方案:#include<cstdlib>通过编译


错误提示:warning: suggest parentheses around '&&' within '||' [-Wparentheses]
方案:源代码:(a[i] >= 65 && a[i] <= 90 || a[i] >= 97 && a[i] <= 122)改为((a[i] >= 65 && a[i] <= 90) || (a[i] >= 97 && a[i] <= 122))即可

错误:用如下代码以二进制读写方式打开文件a.dat失败。
fstream iofile("a.dat",ios::in|ios::out|ios::binary);
if(!iofile){
cerr<<"file error!"<<endl;
exit(1);
}
方案: C++库函数中用流fstream打开文件默认方式是ios::in,ios::out,用ios::binary打开方式后,要定义写入方式,因为已经默认能写了。加入ios::trunc或ios::app都行。
但是这样写入的方式就改变了,由in变为了app。仍然使用 fstream iofile("a.dat",ios::in|ios::out|ios::binary);的方法是事先在当前文件夹下建立a.dat文件,就可以打开成功。

错误提示:error: 'strcpy' was not declared in this scope
方案:#include<string>

你可能感兴趣的:(解决方案)