ChinaUnix.net
相关文章推荐:

无法将类型void”隐式转换为SystemDataDataTable”

我的函数要带进来许多类型的参数,所以我在函数定义时用void代替具体的参数类型,如下: int m2stru(msg,i) void msg; int i; { struct st100 s100; if(i == 100) { memcpy(&s100,(struct st100 *)&msg,sizeof(struct st100)); } ... } 但编译时出错,说Operand must be a scalar type,不知道什么意思。这种情况下应该怎么做?

by jchc - C/C++ - 2005-01-13 15:01:07 阅读(2680) 回复(2)

相关讨论

用dynamic_cast会报错,用static_cast的话又不能判断该 void*是否真的是指向一个该class的对象 有什么比较安全的做法吗?

by softmachine - C/C++ - 2005-12-03 13:41:20 阅读(792) 回复(1)

[code]#include #include int test(vod *arg) { char *local_arg[2]; local_arg[0] = ???; // How to do this here? local_arg[1] = ???: fprintf(stderr, "%s\n", local_arg[0]); fprintf(stderr, "%s\n", local_arg[1]); return 0; } int main(int argc, char *argv[]) { char *arg[2] = {"hello", "world"} test(arg); return 0; } [/code]

by wintersky - C/C++ - 2007-05-07 10:00:44 阅读(5534) 回复(2)

比如 [code]time_t time(time_t *tloc);[/code] 原本是返回一个time_t类型的值,但是却这样调用 (void)time(timeval); 在调用函数时,在函数明明有返回值的情况下, 强制转换void类型,这又有什么玄机呢? 是说明不需要返回值吗?但函数定义时已经定义了返回值,这样编译器为何不会报错呢? 比如下面红色部分; [code]#include #include #include #include #include int main(void) ...

by kerom - C/C++ - 2008-06-19 14:51:14 阅读(1389) 回复(7)

声明了一个如下类型的函数指针 [code]int (*cmd)(arg1,arg2);[/code] 程序我是这样写的: [code] dp=dlopen(...); cmd=dlsym(dp,“cmd”); [/code] 用g++编译返回错误是: [code] invalid conversion from `void*' to `int (*)(arg1, arg2)' [/code] c++里边应该怎么进行这样的转换

by wmytch - C/C++ - 2005-09-14 14:12:02 阅读(3201) 回复(4)

#include; #include; #include; #include; #include; #include; struct student {int num; char name[20]; int score[3]; struct student *next; }; student * head; int n; student *create() {student *pend;student *p; p=pend=(struct student)malloc(sizeof(struct student)); // cout<<"please input first student`s number:"; scanf("%d",&p->;num);co...

by shining3g - C/C++ - 2003-07-24 13:46:46 阅读(669) 回复(2)

下面是我想用void类型指针指向函数指针,然后用void类型的指针调用函数指针指向的函数,请问该如何操作,谢谢指教:em03: :em03: :em03: [code] #include #include void func(void); int main(void) { void (*pfunc)(void); void *pvoid = NULL; pfunc = func; pvoid = pfunc; pvoid; return 0; } void func(void) { printf("this is a test....

by fcloudf - C/C++ - 2007-11-08 12:31:28 阅读(2012) 回复(5)

程序: #include #include using namespace std; int main() { void *p1; string p2 = "hello,world!"; p1 = &p2; cout<<"p1 = " <

by JustUSTC - C/C++ - 2006-11-12 21:27:53 阅读(1602) 回复(7)

ret = lc_reqsend( sk, &send_head, (void*)&rtdata ) ) != 0

by tedagov - C/C++ - 2005-07-13 17:47:34 阅读(1059) 回复(2)

定义了void fun(const int i)与 void fun(int i) 编译出错 提示:fun(const int )已经存在。

by kewenliang - C/C++ - 2008-06-29 20:20:01 阅读(3147) 回复(7)

返回类型void的函数,里面用了return,为什么会kill掉?

by georgegccn - C/C++ - 2007-04-17 09:25:58 阅读(2579) 回复(4)