标题:【已解决】求助:C++编译错误,不知道怎么办啊,谢谢了
只看楼主
wfjt
Rank: 1
等 级:新手上路
帖 子:121
专家分:0
注 册:2007-11-30
 问题点数:0 回复次数:2 
【已解决】求助:C++编译错误,不知道怎么办啊,谢谢了
求助:编译错误,不知道怎么办啊,谢谢了源代码:
头文件:ListStruct.h

    typedef float DataType; //假设结点的数据类型是字符型
typedef struct node { //结点类型定义
DataType data;
struct node *next;//结点的指针域
}ListNode;
typedef ListNode * LinkList;



ListStruct.cpp

#include "iostream.h"
#include "string"
#include "ListStruct.h"
LinkList CreatList (float ch)
{ //用尾插法建立带头结点的单链表
LinkList head = (LinkList)malloc(sizeof( ListNode)); //生成头结点
ListNode *s , *r;
r=head;//尾指针亦指向头结点
s=(ListNode *) malloc (sizeof(ListNode));
s->data=ch;
r->next=s;
r=s;
r->next=NULL;
return head;
}
void OutList( LinkList L)
{
ListNode *p;
p=L;
while (p->next)
{
cout << p->next->data << " " ;
p=p->next;
}
cout << endl;
}
int main()
{
LinkList A;
cout<<"输入高程:"<<" ";
float er;
cin>>er;
CreatList (er);
return 0;
}



编译错误:


编译器: Default compiler
执行  g++.exe...
g++.exe "E:\Program Files\新建文件夹\ListStruct.cpp" -o "E:\Program Files\新建文件夹\ListStruct.exe"    -I"d:\Dev-Cpp\include\c++"  -I"d:\Dev-Cpp\include\c++\mingw32"  -I"d:\Dev-Cpp\include\c++\backward"  -I"d:\Dev-Cpp\include"   -L"d:\Dev-Cpp\lib"
In file included from d:/Dev-Cpp/include/c++/backward/iostream.h:31,
                 from E:/Program Files/新建文件夹/ListStruct.cpp:1:
d:/Dev-Cpp/include/c++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
E:/Program Files/新建文件夹/ListStruct.cpp: In function..`ListNode*
   CreatList(float)':
E:/Program Files/新建文件夹/ListStruct.cpp:13: warning: assignment to `DataType
   ' from `float'
E:/Program Files/新建文件夹/ListStruct.cpp:13: warning: argument to `char' from
   `float'
E:/Program Files/新建文件夹/ListStruct.cpp: In function..`int main()':
E:/Program Files/新建文件夹/ListStruct.cpp:36: stray '\243' in program
E:/Program Files/新建文件夹/ListStruct.cpp:36: stray '\273' in program
E:/Program Files/新建文件夹/ListStruct.cpp:37: parse error before `>>' token
执行结束


我怎么也改不过来了

求助啊
先谢谢大家了yi

[[italic] 本帖最后由 wfjt 于 2007-11-30 16:42 编辑 [/italic]]
搜索更多相关主题的帖子: 结点 源代码 LinkList ListNode 
2007-11-30 15:21
Janlex
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:303
专家分:0
注 册:2006-9-12
得分:0 
问题一:

#include "iostream.h"改成

#include "iostream"
using namespace std;

原因: g++编译器只支持c++新标准. (名字空间)



问题二:
float er;
改成
float er;

原因:后面的';'语句结束符请换成EN输入法时输入

★★★★★欢迎光临我的博客 ★★★★★
http://www.
2007-11-30 15:31
wfjt
Rank: 1
等 级:新手上路
帖 子:121
专家分:0
注 册:2007-11-30
得分:0 
万分感谢版主!
请你吃饭
2007-11-30 16:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-189539-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.508568 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved