注册 登录
编程论坛 C++教室

高手请教,新手一事不明

两条线 发布于 2012-07-24 21:48, 348 次点击
我有一个源代码,但编译不了,如下:
#include<iostream>
using namespace std;
int mian()
{
    string str1(5,'*');
    cout<<"输出str1的值:"<<str1<<endl;
    system("pause");
     return 0;
}
显示错误:
  [Linker error] undefined reference to `WinMain@16' ld returned 1 exit status
不知如何,望高手解答,最好能详细一点!
1 回复
#2
有容就大2012-07-24 22:21
程序代码:
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string str1(5,'*');
    cout<<"输出str1的值:" << str1 << endl;
    system("pause");
     return 0;
}
上面是修改后的程序。
你需要注意几个问题。
1. 你检查下是不是在 Win32 Console Application下建立的工程? 要确保是在他下面。
2. 你的程序需要主函数入口 把 mian 改成 main
3. C++  使用string 类型时 需要包含 一个头文件 #include <string>.
1