为什么老是报错,不懂,求解

zc806 2011-04-22 05:03:57

#include "stdafx.h"
#include <iostream>
#include <tchar.h>



using namespace std;

#define M 3000
_TUCHAR nX[];
_TUCHAR nY[];
int nResult[M];



int _tmain(int argc, _TCHAR* argv[])
{
int x,y;
cout << "Please input nX = ";
cin >> x;

int i = 0;
while( x != 0) {
int m = x % 10;
nX[i] = m;
x = x/10;
}

}

老是提示BigNum.obj : error LNK2001: 无法解析的外部符号 "unsigned char * nX" (?nX@@3PAEA)
Debug/xxx.exe : fatal error LNK1120: 1 个无法解析的外部命令
...全文
70 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
一根烂笔头 2011-04-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 newstudent_never 的回复:]
#define M 3000
_TUCHAR nX[];
_TUCHAR nY[];
数组没指定大小 怎么能用呢?
_TUCHAR nX[M];
_TUCHAR nY[M];
[/Quote]
一般数组的定义(栈内存中):
数据类型 数组标识符[常量表达式];
其中常量表达式,不允许是变量。
zc806 2011-04-22
  • 打赏
  • 举报
回复
低级错误
zc806 2011-04-22
  • 打赏
  • 举报
回复
晕,忘写了,没看见,哈哈
c_losed 2011-04-22
  • 打赏
  • 举报
回复

#include "stdafx.h"
#include <iostream>
#include <tchar.h>



using namespace std;

#define M 3000

_TUCHAR nY[];
int nResult[M];



int _tmain(int argc, _TCHAR* argv[])
{
_TUCHAR nX[256];

int x,y;
cout << "Please input nX = ";
cin >> x;

int i = 0;
while( x != 0) {
int m = x % 10;
nX[i] = m;
x = x/10;
}

}

xmu_才盛 2011-04-22
  • 打赏
  • 举报
回复
#define M 3000
_TUCHAR nX[];
_TUCHAR nY[];
数组没指定大小 怎么能用呢?
_TUCHAR nX[M];
_TUCHAR nY[M];

64,683

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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