C++错误error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用

qq_16319743 2015-04-16 03:01:59
C++编译提示错误error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
错误 2 error LNK1120: 1 个无法解析的外部命令
CSND上的大神们 这个怎么弄啊

头文件.c:
#ifndef COORDIN_H_
#define COORDIN_H_

struct polar
{
double distance;
double angle;
};
struct rect
{
double x;
double y;
};
polar rect_to_polar(rect xypos);
void show_polar(polar dapos);

#endif
函数实现.cpp:
#include <iostream>
#include <cmath>
#include "coordin.h"

polar rect_to_polar(rect xypos)
{
using namespace std;
polar answer;

answer.distance = sqrt(xypos.x * xypos.x + xypos.y * xypos.y);
answer.angle = atan2(xypos.y, xypos.x);
return answer;
}

void show_polar(polar dapos)
{
using namespace std;
const double Rad_to_deg = 57.29577951;

cout << "distance = " << dapos.distance;
cout << ", angle = " << dapos.angle * Rad_to_deg;
cout << " degrees\n";
}
源文件.cpp:
#include <iostream>
#include "coordin.h"
using namespace std;
void main(void)
{
rect rplace;
polar pplace;

cout << "Enter the x and y values: ";
while (cin >> rplace.x >> rplace.y)
{
pplace = rect_to_polar(rplace);
show_polar(pplace);
cout << "Next two nubers (q to quit): ";
}
cout << "Bye!\n";
}
...全文
2121 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Arrogant_zhang 2017-04-14
  • 打赏
  • 举报
回复
一般情况下应该是源函数里面没有创建main()函数,在源.cpp里面加上int main(){}就好了。
赵4老师 2015-04-16
  • 打赏
  • 举报
回复
void main(void) 改为 int main() 试试看。
生活的苦涩 2015-04-16
  • 打赏
  • 举报
回复
你是不是打开过多个解决方案啊,可能是之前的解决方案没有彻底关闭导致的..
Aist-memory 2015-04-16
  • 打赏
  • 举报
回复
函数实现要写在CPP源文件里
william7_138 2015-04-16
  • 打赏
  • 举报
回复
这位同学,我用你贴出来的代码建了一个程序,编译通过,既然你的程序是控制台程序,这个问题的原因很有可能就是你的代码中没有main函数,所以报错,你再看看。

70,023

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧