为什么 "Visual C++ 2008 Express Edition" 不是编译简单的 C++ 程序?

Why "Visual C++ 2008 Express Edition" is not Compiling a Simple C++ Program?

不要浪费您的时间,简短的描述对于描述问题很重要。 它没有编译以下程序,并在我尝试构建时出现 example.exe 未找到的错误消息。

#include <iostream>
using namespace std;
main()
{
    string name, surname;
    cout << "Enter your name: ";
    cin >> name;
    cout << "Enter your surname: ";
    cin >> surname;
    cout << "Welcome " << name << " " << surname;
 return 0;
}

当我尝试在 Visual C++ 中使用 GCC 编译器构建它时,您的代码正在为我工​​作。 注意:其他 C++ 编译器需要您使用

声明主函数

int main() and you must have to create a header file main.h and include all libraries that you want to use. as I show you in my example of code. Try this code it should work on your end as well. Just you need to create an extra header file main.h and include iostream and string in it.

#include <iostream>
#include "main.h"
using namespace std;
main()
{
    string name, surname;
    cout << "Enter your name: ";
    cin >> name;
    cout << "Enter your surname: ";
    cin >> surname;
    cout << "Welcome " << name << " " << surname;
}