操作系统:Windows10。编译器是MingW(gcc的windows实现)。
①下载
进入Binary releases - Code::Blocks
下载.zip解压后 点击CbLauncher.exe 就打开了。
②设置C++11. setting -> compiler
运行
③设置运行快捷键 setting -> editor 。添加快捷键时需要敲击你想要的键盘按键
④调出底端界面(运行报错信息在此)View -> perspective -> default 或者 delete current。
⑤测试(遍历某文件夹下的文件,Linux和Windows上通用;io.h的方式只能用于Windows)
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <iostream>
using namespace std;
int main(int argc,char *argv[])
{
DIR *dp;
struct dirent *dirp;
int n=0;
if((dp=opendir("C:\\Users\\"))==NULL)
printf("can't open the dir !");
cout << "Your dir must include two d_name, it`s '.' and '..'" << std::endl;
while (((dirp=readdir(dp))!=NULL) && (n<=450))
{
n++;
printf("%-6d%s\n", n, dirp->d_name);
}
printf("\n");
closedir(dp);
return 0;
}
io.h遍历的方式在Linux平台上 一般不能正常编译,报错为【fatal error: io.h: No such file or Directory #include <io.h>】