新手求助。关于源程序使用了MFC内容的问题。
源程序其中一个.c文件如下..仿照C语言数据结构课本的程序写的.结果一编译就报错"microsoft visual studio\vc98\mfc\include\afx.h(15) : fatal error C1189: #error : MFC requires C++ compilation (use a .cpp suffix)
执行 cl.exe 时出错."
何解???
#include "dcourse.h"
#include "dinfo.h"
#include "dcomm.h"
#include <stdlib.h>
#include <string.h>
PCOURSE_NODE CourseLinkHead;
COURSE_NODE * NewCourseNode();
void CourseNodeInit(COURSE_NODE *_pCourseNode);
void CourseNodeCopy(COURSE_NODE *_pTargetCourseNode,COURSE_NODE *_pSourceCourseNode);
int CourseNodeInsertByNode(PCOURSE_NODE *_pCourseLinkHead,COUESE_NODE *_pNewCourseNode);
int CourseNodeAppend(PCOURSE_NODE *_pCourseLinkHead,COURSE_NODE *_pNewCourseNode);
int CourseNodeDelete(PCOURSE_NODE *_pCourseLinkHead,char *_cCourseId);
void CourseLinkDelete(PCOURSE_NODE *_pCourseLinkHead);
COURSE_NODE * GetCourseNodeByCourseId(PCOURSE_NODE *_pCourseLinkHead,char *_cCourseId);
COURSE_NODE * NewCourseNode()
{
COURSE_NODE *_pCourseNode;
_pCourseNode= (COURSE_NODE *)malloc(sizeof(COURSE_NODE)); / 新建课程 /
CourseNodeInit(_pCourseNode); / 课程初始化 /
return _pCourseNode;
}
void CourseNodeInit(COURSE_NODE *_pCourseNode)
{
strcpy(_pCourseNode->data.CourseId," ");
strcpy(_pCourseNode->data.CourseName," ");
strcpy(_pCourseNode->data.MasterName," ");
strcpy(_pCourseNode->data.Tel," ");
_pCourseNode->pInfoHead= NULL; / 初始化课程信息链表表头 /
_pCourseNode->pNext= NULL;
}
void CourseNodeCopy(COURSE_NODE *_pTargetCourseNode,COURSE_NODE *_pSourceCourseNode)
{
strcpy(_pTargetCourseNode->data.CourseId,_pSourceCourseNode->data.CourseId);
strcpy(_pTargetCourseNode->data.CourseName,_pSourceCourseNode->data.CourseName);
}
int CourseNodeInsertByNode(PCOURSE_NODE *_pCourseLinkHead,COUESE_NODE *_pNewCourseNode)
{
COURSE_NODE *p1, *_p2, *_pMyCourseNode;
_p1= (*_pCourseLinkHead); / 生成新结点 /
_pMyCourseNode= NewCourseNode(); / 创建空的课程结点 /
CourseNodeCopy(_pMyCourseNode, _pNewCourseNode);
if((*_pCourseLinkHead==NULL)
{
(*_pCourseLinkHead)= _pMyCourseNode;
}
else
{
while((strcmp(_pMyCourseNode->data.CourseId, _p1->data.CourseId)>0)&&(_p1->pNext!=NULL))
{
_p2= _p1;
_p1= _p1->pNext;
}
if( strcmp(_pMyCourseNode->data.CourseId, _p1->data.CourseId)<0)
{
if((*_pCourseLinkHead)==_p1)
{
(*_pCourseLinkHead)= _pMyCourseNode;
_pMyCourseNode->pNext= _p1;
}
else
{
_p2->pNext= _pMyCourseNode;
_pMyCourseNode->pNext= _p1;
}
}
else if( strcmp(_pMyCourseNode->data.CourseId, _p1->data.CourseId)==0)
{
free(_pMyCourseNode);
return 0;
}
else if(_p1->pNext==NULL)
{
_p1->pNext= _pMyCourseNode;
}
}
return 1;
}
int CourseNodeAppend(PCOURSE_NODE *_pCourseLinkHead,COURSE_NODE *_pNewCourseNode)
{
COURSE_NODE *_p1, *_p2, *_pMyCourseNode;
_p1= (*_pCourseLinkHead);
_pMyCourseNode= NewCourseNode();
CourseNodeCopy(_pMyCourseNode, _pNewCourseNode);
if((*_pCourseLinkHead)==NULL)
{
(*_pCourseLinkHead)= _pMyCourseNode;
}
else
{
while(_p1->pNext!=NULL)
{
if( strcmp(_pMyCourseNode->data.CourseId, _p1->data.CourseId)==0 )
{
free(_pMyCourseNode);
return 0;
}
else
{
_p2= _p1;
_p1= _p1->pNext;
}
}
_p2->pNext= _pMyCourseNode;
_pMyCourseNode->pNext= _p1;
return 1;
}
}
int CourseNodeDelete(PCOURSE_NODE *_pCourseLinkHead,char *_cCourseId)
{
COURSE_NODE *_p1,*_p2;
_p1= (*_pCourseLinkHead);
_p2=_p1;
while( (strcmp(_p1->data.CourseId, _cCourseId)!=0 ) && ( _p1!=NULL) )
{
_p2= _p1;
_p1= _p1->pNext;
}
if(_p1!=NULL)
{
_p2->pNext= _p1->pNext;
InfoLinkDelete( _p1->pInfoHead);
if(_p1==(*_pCourseLinkHead) )
{
(*_pCourseLinkHead)=_p1->pNext;
}
free(_p1);
return NOERR;
}
else
{
return ERR;
}
}
void CourseLinkDelete(PCOURSE_NODE *_pCourseLinkHead)
{
COURSE_NODE *_p1, *_p2;
_p1= (*_pCourseLinkHead);
while(_p1!=NULL)
{
_p2=_p1->pNext;
InfoLinkDelete(_p1->pInfoHead);
free(_p1);
_p1=_p2;
}
(*_pCourseLinkHead)=NULL;
}
COURSE_NODE * GetCourseNodeByCourseId(PCOURSE_NODE *_pCourseLinkHead,char *_cCourseId)
{
COURSE_NODE *_p1;
_p1=(*_pCourseLinkHead);
while(_p1!=NULL)
{
if(strcmp(_p1->data.CourseId, _cCourseId)==0)
{
break;
}
_p1= _p1->pNext;
}
return _p1;
}