关于C结构体中定义函数有关问题

关于C结构体中定义函数问题#includestdio.h#includestdlib.hstructtest{intivoidset()}voidmain(){

关于C结构体中定义函数问题
#include   <stdio.h>
#include   <stdlib.h>

struct   test
{
int   i;

void   set();
};

void   main()
{
}

提示说   “function   cannot   be   member   of   struct   'test '”
C结构体中不是可以定义函数的吗?

[解决办法]
恩?我怎么没听说过?搂住说得是不是真的?
我只用过函数指针,再就是将结构体传给函数!搂住你再仔细确认一下!
[解决办法]
C++中struct里是可以定义成员函数,C中不行,不过你可以定义一个函数指针变量
struct test
{
int i;
void (*pfun)(struct test*, int);
}

void set(struct test* t, int n)
{
t-> i = n;
}

void f()
{
test t;
t-> pfun = set;
t-> pfun(&t, 2);
}