老问题 老ERROR

GResume 2010-03-15 09:03:25
我发现VC++6.0报错真是噩梦,要找到哪里错了还需要丰富经验,现在来求求各路神仙指点,我这个报错是说我哪里错了
报错很长,不过大意就3个

1.没“;”。辩护:但我确实写了,也不至于忘了这么多次,我估计是别的地方错了,高手们有经验的应该看的出来吧,帮帮我先。

2.变量没有类型,类型未定义,出错的地方典型举例如下:
tm* dest;
string m_string;
辩护:我确实包含了头文件time.h 和string.h,而且有一点我很奇怪,我用了time.h中的tm类型和time_t类型,代码中的tm类型的语句统统报错,而time_t类型的语句全部通过了,请高手们指引。

3.这句错误比较特别 不懂 求解
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(98) : error C2064: term does not evaluate to a function
出错语句为 : calender = time();
//其中calender是一个time_t类型,这个赋值句我是剪别人的,不知道怎么会错


全部报错如下:
--------------------Configuration: 哥只是传说 - Win32 Debug--------------------
Compiling...
哥只是传说.cpp
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(38) : error C2143: syntax error : missing ';' before '*'
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(38) : error C2501: 'time' : missing storage-class or type specifiers
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(38) : error C2501: 'calender' : missing storage-class or type specifiers
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(39) : error C2143: syntax error : missing ';' before '*'
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(39) : error C2501: 'time' : missing storage-class or type specifiers
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(39) : error C2501: 'count' : missing storage-class or type specifiers
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(41) : error C2146: syntax error : missing ';' before identifier 'm_string'
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(41) : error C2501: 'string' : missing storage-class or type specifiers
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(41) : error C2501: 'm_string' : missing storage-class or type specifiers
哥只是传说Dlg.cpp
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(38) : error C2143: syntax error : missing ';' before '*'
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(38) : error C2501: 'time' : missing storage-class or type specifiers
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(38) : error C2501: 'calender' : missing storage-class or type specifiers
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(39) : error C2143: syntax error : missing ';' before '*'
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(39) : error C2501: 'time' : missing storage-class or type specifiers
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(39) : error C2501: 'count' : missing storage-class or type specifiers
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(41) : error C2146: syntax error : missing ';' before identifier 'm_string'
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(41) : error C2501: 'string' : missing storage-class or type specifiers
d:\我的电脑实验室\哥只是传说\哥只是传说dlg.h(41) : error C2501: 'm_string' : missing storage-class or type specifiers
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(98) : error C2065: 'calender' : undeclared identifier
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(98) : error C2064: term does not evaluate to a function
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(101) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(101) : error C2086: 'dest' : redefinition
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(101) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(102) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(102) : error C2086: 'dest' : redefinition
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(102) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(103) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(103) : error C2086: 'dest' : redefinition
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(103) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(104) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(104) : error C2086: 'dest' : redefinition
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(104) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(105) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(105) : error C2086: 'dest' : redefinition
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(105) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(106) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(106) : error C2086: 'dest' : redefinition
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(106) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(107) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(107) : error C2086: 'dest' : redefinition
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(107) : error C2143: syntax error : missing ';' before '->'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(108) : error C2664: 'mktime' : cannot convert parameter 1 from 'struct tm' to 'struct tm *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(109) : error C2100: illegal indirection
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(110) : error C2065: 'string' : undeclared identifier
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(110) : error C2146: syntax error : missing ';' before identifier 'tempString'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(110) : error C2065: 'tempString' : undeclared identifier
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(111) : error C2296: '%' : illegal, left operand has type 'double'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(114) : error C2146: syntax error : missing ';' before identifier 'tempString'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(115) : error C2065: 'm_string' : undeclared identifier
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(118) : error C2146: syntax error : missing ';' before identifier 'tempString'
D:\我的电脑实验室\哥只是传说\哥只是传说Dlg.cpp(122) : error C2146: syntax error : missing ';' before identifier 'tempString'
Generating Code...
执行 cl.exe 时出错.

哥只是传说.exe - 1 error(s), 0 warning(s)


非常感谢您的时间!
...全文
112 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
GResume 2010-03-15
  • 打赏
  • 举报
回复
哇 谢谢楼上 我太无知了 明日结贴哈
logiciel 2010-03-15
  • 打赏
  • 举报
回复
给tm*分配空间:

struct tm *dest;
dest=(struct tm*)malloc(sizeof(struct tm));
GResume 2010-03-15
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 thefirstz 的回复:]
void CMyDlg::IniTime()
{
type_t calender = time();
time = localtime(calender);
tm* dest;
tm* dest-> tm_year = 2010; //把前面的tm*去掉,另外需要为struct tm* test分配空间tm* dest-> tm_mon = 5;//redefination 如果不想分配……
[/Quote]
用 struct tm dest这个方法通过编译了,谢谢,还想问问怎么给tm*分配空间哈,或者是没有这个办法?
GResume 2010-03-15
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 thefirstz 的回复:]
void CMyDlg::IniTime()
{
type_t calender = time();
time = localtime(calender);
tm* dest;
tm* dest-> tm_year = 2010; //把前面的tm*去掉,另外需要为struct tm* test分配空间tm* dest-> tm_mon = 5;//redefination 如果不想分配……
[/Quote]
啊 请问给tm*分配空间要怎么做 谢谢
GResume 2010-03-15
  • 打赏
  • 举报
回复
改成这样了 也不行…………
struct tm* dest;
dest-> tm_year = 2010;
dest-> tm_mon = 5;
dest-> tm_mday = 1;
dest-> tm_sec = 0;
dest-> tm_min = 0;
dest-> tm_hour = 0;
dest-> tm_wday = 6;
昵称很不好取 2010-03-15
  • 打赏
  • 举报
回复
void CMyDlg::IniTime()
{
type_t calender = time();
time = localtime(calender);
tm* dest;
tm* dest-> tm_year = 2010; //把前面的tm*去掉,另外需要为struct tm* test分配空间tm* dest-> tm_mon = 5;//redefination 如果不想分配空间,就用struct tm test;tm* dest-> tm_mday = 1;//redefination 然后test.tm_year这样使用tm* dest-> tm_sec = 0; // redefination
tm* dest-> tm_min = 0; //redefination
tm* dest-> tm_hour = 0;//redefination
tm* dest-> tm_wday = 6;//redefination
time_t destTime = mktime(dest);
diff = difftime( destTime,*calender);
string tempString;
switch (diff%3)
{
case 0:
string tempString("宜送钟");
m_string = tempString;
break;
case 1:
string tempString("宜松土");
m_string = tempString;
break;
case 2:
string tempString("诸事不宜");
m_string = tempString;
break;
}
return;
}
GResume 2010-03-15
  • 打赏
  • 举报
回复
void CMyDlg::IniTime()
{
type_t calender = time();
time = localtime(calender);
tm* dest;
tm* dest-> tm_year = 2010; //redefination
tm* dest-> tm_mon = 5;//redefination
tm* dest-> tm_mday = 1;//redefination
tm* dest-> tm_sec = 0; // redefination
tm* dest-> tm_min = 0; //redefination
tm* dest-> tm_hour = 0;//redefination
tm* dest-> tm_wday = 6;//redefination
time_t destTime = mktime(dest);
diff = difftime( destTime,*calender);
string tempString;
switch (diff%3)
{
case 0:
string tempString("宜送钟");
m_string = tempString;
break;
case 1:
string tempString("宜松土");
m_string = tempString;
break;
case 2:
string tempString("诸事不宜");
m_string = tempString;
break;
}
return;
}

我现在怀疑问题出在红色部分,请问各位怎么处理才能避免重复定义
昵称很不好取 2010-03-15
  • 打赏
  • 举报
回复
tm --> struct tm
别的没代码看不出来问题
某某9 2010-03-15
  • 打赏
  • 举报
回复
你真是个传说啊!
GResume 2010-03-15
  • 打赏
  • 举报
回复
补充问题 见 3楼

64,654

社区成员

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

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