一段小程序,出错了,各位帮帮忙

tracyjk 2011-02-17 04:02:21

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <memory.h>
#include <unistd.h>
#include <ctype.h>
#include <pwd.h>
#include <fcntl.h>
#include <termios.h>
#include <errno.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>


typedef struct _IRDA_ELECT
{
char total[10];
char high[10];
char low[10];
}IRDA_ELECT;
typedef struct IRDA_ELECT * PIRDA_ELECT;


typedef struct _USRINFO
{
char prc_code[10];
char mr_sn[5 + 1];
}USRINFO;
typedef struct USRINFO * PUSRINFO;


typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO;
typedef struct FOUINFO * PFOUINFO;



int price_cacl(IRDA_ELECT Irda_elect,PFOUINFO pFouinfo)
{
float flat;
flat = atof(Irda_elect.total)-atof(Irda_elect.high)-atof(Irda_elect.low);
printf("T is %s--H is %s--L is %s--F is %f\n",Irda_elect.total,Irda_elect.high,Irda_elect.low,flat);

printf("prc_code is %s\n",pFouinfo->usrinfo.prc_code);
}

main()
{
IRDA_ELECT Irda_elect;
FOUINFO Fouinfo;
memset(&Irda_elect,0x00,sizeof(IRDA_ELECT));
memset(&Fouinfo,0x00,sizeof(FOUINFO));

sprintf(Irda_elect.total,"%s","80");
sprintf(Irda_elect.high,"%s","20");
sprintf(Irda_elect.low,"%s","20");
sprintf(Fouinfo.usrinfo.prc_code,"%s","40101019");
price_cacl(Irda_elect,&Fouinfo);
}



出现如下错误:
price.c: In function `price_cacl':
price.c:65: error: dereferencing pointer to incomplete type
price.c: In function `main':
price.c:79: warning: passing arg 2 of `price_cacl' from incompatible pointer type
查了下说是结构体的问题,但是找不到原因...
...全文
67 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouhaitao19821023 2011-02-17
  • 打赏
  • 举报
回复
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <memory.h>
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>


typedef struct _IRDA_ELECT
{
char total[10];
char high[10];
char low[10];
}IRDA_ELECT;
typedef IRDA_ELECT* PIRDA_ELECT;


typedef struct _USRINFO
{
char prc_code[10];
char mr_sn[5 + 1];
}USRINFO;
typedef USRINFO* PUSRINFO;


typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO;
typedef FOUINFO* PFOUINFO;

int price_cacl(IRDA_ELECT Irda_elect,PFOUINFO pFouinfo)
{
float flat;
flat = atof(Irda_elect.total)-atof(Irda_elect.high)-atof(Irda_elect.low);
printf("T is %s--H is %s--L is %s--F is %f\n",Irda_elect.total,Irda_elect.high,Irda_elect.low,flat);

printf("prc_code is %s\n",pFouinfo->usrinfo.prc_code);
return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
IRDA_ELECT Irda_elect;
FOUINFO Fouinfo;
memset(&Irda_elect,0x00,sizeof(IRDA_ELECT));
memset(&Fouinfo,0x00,sizeof(FOUINFO));

sprintf(Irda_elect.total,"%s","80");
sprintf(Irda_elect.high,"%s","20");
sprintf(Irda_elect.low,"%s","20");
sprintf(Fouinfo.usrinfo.prc_code,"%s","40101019");
price_cacl(Irda_elect,&Fouinfo);
getchar();
return 0;
}
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <memory.h>
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>


typedef struct _IRDA_ELECT
{
char total[10];
char high[10];
char low[10];
}IRDA_ELECT;
typedef IRDA_ELECT* PIRDA_ELECT;


typedef struct _USRINFO
{
char prc_code[10];
char mr_sn[5 + 1];
}USRINFO;
typedef USRINFO* PUSRINFO;


typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO;
typedef FOUINFO* PFOUINFO;

int price_cacl(IRDA_ELECT Irda_elect,PFOUINFO pFouinfo)
{
float flat;
flat = atof(Irda_elect.total)-atof(Irda_elect.high)-atof(Irda_elect.low);
printf("T is %s--H is %s--L is %s--F is %f\n",Irda_elect.total,Irda_elect.high,Irda_elect.low,flat);

printf("prc_code is %s\n",pFouinfo->usrinfo.prc_code);
return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
IRDA_ELECT Irda_elect;
FOUINFO Fouinfo;
memset(&Irda_elect,0x00,sizeof(IRDA_ELECT));
memset(&Fouinfo,0x00,sizeof(FOUINFO));

sprintf(Irda_elect.total,"%s","80");
sprintf(Irda_elect.high,"%s","20");
sprintf(Irda_elect.low,"%s","20");
sprintf(Fouinfo.usrinfo.prc_code,"%s","40101019");
price_cacl(Irda_elect,&Fouinfo);
getchar();
return 0;
}
编译没错,运行输出为
T is 80--H is 20--L is 20--F is 40.000000
prc_code is 40101019
huhacn 2011-02-17
  • 打赏
  • 举报
回复
//////////////////////////////////////////////////////////////////////////
typedef struct _IRDA_ELECT
{
char total[10];
char high[10];
char low[10];
}IRDA_ELECT, *PIRDA_ELECT;
//typedef IRDA_ELECT * PIRDA_ELECT;


typedef struct _USRINFO
{
char prc_code[10];
char mr_sn[5 + 1];
}USRINFO, * PUSRINFO;
//typedef USRINFO * PUSRINFO;


typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO ,*PFOUINFO;
//typedef FOUINFO * PFOUINFO;

int price_cacl(IRDA_ELECT Irda_elect,PFOUINFO pFouinfo)
{

}

//////////////////////////////////////////////////////////////////////////
huhacn 2011-02-17
  • 打赏
  • 举报
回复

//////////////////////////////////////////////////////////////////////////
typedef struct _IRDA_ELECT
{
char total[10];
char high[10];
char low[10];
}IRDA_ELECT, *PIRDA_ELECT;
//typedef IRDA_ELECT * PIRDA_ELECT;


typedef struct _USRINFO
{
char prc_code[10];
char mr_sn[5 + 1];
}USRINFO, * PUSRINFO;
//typedef USRINFO * PUSRINFO;


typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO ,*PFOUINFO;
//typedef FOUINFO * PFOUINFO;

int price_cacl(IRDA_ELECT Irda_elect,PFOUINFO pFouinfo)
{

}

//////////////////////////////////////////////////////////////////////////
huhacn 2011-02-17
  • 打赏
  • 举报
回复

//////////////////////////////////////////////////////////////////////////
typedef struct _IRDA_ELECT
{
char total[10];
char high[10];
char low[10];
}IRDA_ELECT, *PIRDA_ELECT;
//typedef IRDA_ELECT * PIRDA_ELECT;


typedef struct _USRINFO
{
char prc_code[10];
char mr_sn[5 + 1];
}USRINFO, * PUSRINFO;
//typedef USRINFO * PUSRINFO;


typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO ,*PFOUINFO;
//typedef FOUINFO * PFOUINFO;

int price_cacl(IRDA_ELECT Irda_elect,PFOUINFO pFouinfo)
{

}

//////////////////////////////////////////////////////////////////////////
tracyjk 2011-02-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dingwo006 的回复:]
typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO;
typedef struct FOUINFO * PFOUINFO;


改成
typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO;
typedef FO……
[/Quote]

谢谢,可以了
基础还是太差了!有待加强
一曲肝肠断 2011-02-17
  • 打赏
  • 举报
回复
typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO;
像这种 FOUINFO已经被定义成一种类型数据了吧,

然后直接typedef FOUINFO * PFOUINFO;就可以了。
上面的那些结构体好像都有类似的问题。
一曲肝肠断 2011-02-17
  • 打赏
  • 举报
回复
typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO;
typedef struct FOUINFO * PFOUINFO;


改成
typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO;
typedef FOUINFO * PFOUINFO;

或者
typedef struct _FOUINFO
{
USRINFO usrinfo;
char a[2];
}FOUINFO;
typedef struct _FOUINFO * PFOUINFO;

试试

69,382

社区成员

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

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