struct showmessage* p=new showmessage;
struct showmessage* q;
q=GetKeyWord(p);
MessageBox(q->buff);
这个是我的主函数中的调用GetKeyWord()函数的代码;
GetKeyWord()的定义:
(struct showmessage*) GetKeyWord(struct showmessage* p)
{
p->buff="hi,boy!"
retrun p;
}
showmessage 结构体的定义
struct showmessage
{
char buff[10];
};
请问这样可以吗?我编译的时候总说unexpected type 'showmessage'
请问应该怎么改啊?

解决方案 »

  1.   

    p->buff="hi,boy!"错误,改为
    strcpy(p->buff, "hi,boy!");另外,你的struct showmessage
    {
    char buff[10];
    };
    要放在函数GetKeyWord前面
      

  2.   

    你可以typedef struct tagshowmessage showmessage;
    struct tagshowmessage 
    {
    char buff[10];
    };就不用天天拿着struct了另外.你不需要返回指针了.因为 调用完GetKeyWord(struct showmessage* p)后.buff的值已经变了
      

  3.   

    unexpected type 'showmessage'?
    GetKeyWord定义之处struct showmessage的定义必须可见