【发布时间】:2013-11-16 15:48:25
【问题描述】:
当我编译我的 secrypt.cpp 程序时,我的编译器显示错误“undefined reference to WinMain@16”。
我的代码如下
secrypt.h:
#ifndef SECRYPT_H
#define SECRYPT_H
void jRegister();
#endif
secrypt.cpp:
#include<iostream>
#include<string>
#include<fstream>
#include<cstdlib>
#include "secrypt.h"
using namespace std;
void jRegister()
{
ofstream outRegister( "useraccount.dat", ios::out );
if ( !outRegister ) {
cerr << "File could not be opened" << endl;
exit( 1 );}
string a,b,c,d;
cout<<"enter your username :";
cin>>a;
cout<<"enter your password :";
cin>>b;
outRegister<<a<<' '<<b<<endl;
cout<<"your account has been created";
}
试用.cpp
#include<iostream>
#include "secrypt.h"
using namespace std;
int main()
{
void jRegister();
return 0;
}
这是我的错误的图像: errorimage
当我编译我的 trial.cpp 程序时,它编译并打开控制台,但没有调用该函数。这是 trial.cpp 程序的控制台屏幕图像。 o/p screen 谁能帮我解决这个问题?
【问题讨论】:
-
你永远不会编译和链接
trial.cpp。 -
编译为控制台模式程序。
-
@Max,可能是。
-
它查找 GUI 程序。它不查找 main(),而是查找 WinMain。将您的项目属性更改为控制台程序
-
@AlexandreTryHardLeblanc,图片显示没有项目。
WinMain即使是 Win32 GUI 项目也不需要。
标签: c++ windows codeblocks