我是QT的新手,我很难理解在执行main函数之前如何确定操作系统.我是这个领域的一个完整的新手,所以任何指导将不胜感激.
我想确定该程序是否在以下某个环境中运行:
Windows
Unix
Linux
Mac
Run Code Online (Sandbox Code Playgroud)
另外我如何在main函数中使用这些数据?
非常感谢
所以我刚开始学习C++,我想在Linux上测试我的第一个程序.这是我的计划:
#include <cstdlib>
#include <iostream>
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_YELLOW "\x1b[33m"
#define ANSI_COLOR_BLUE "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN "\x1b[36m"
#define ANSI_COLOR_RESET "\x1b[0m"
using namespace std;
void main_header()
{
printf (ANSI_COLOR_GREEN "+---------------+---------------¦ " ANSI_COLOR_RESET "\n");
printf (ANSI_COLOR_GREEN "+---------" ANSI_COLOR_RED " THE GENERAL " "---------¦" ANSI_COLOR_RESET "\n");
printf (ANSI_COLOR_GREEN "+---------------+---------------¦ " ANSI_COLOR_RESET "\n");
}
int main()
{
main_header();
system("PAUSE");
return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Bloodshed来编译程序.在我完成程序后,我通过FTP上传并执行dos2unix main.cpp.然后我尝试运行该程序,但我收到此错误:
./main.cpp: line 12: using: command not found
./main.cpp: line 16: syntax error …Run Code Online (Sandbox Code Playgroud)