ChinaUnix.net
相关文章推荐:

void Setclkvoid

在C和C++里,有时候看到源码中调用函数前加上“void”,不知道有什么作用,即 (void)function(argument) 这只是单纯为了形式的规整吗?请教诸位

by hoverlee - C/C++ - 2006-07-12 21:00:37 阅读(896) 回复(9)

相关讨论

有个函数int A(..., ..., void *buf),想在函数里面跟据情况在buf中返回不同长度、不同类型的一段空间,有没有问题???请问大家。

by eikes - C/C++ - 2005-12-15 19:24:52 阅读(788) 回复(2)

void hello(void*arg) { char*kk="hello"; arg=(void*)kk; return NULL; } main() { void*k; hello(k); char *k2=(char*)k; printf("%s",k); exit(0); } when running ,I get 8Z@ ,not hello,why? thanks for looking at my question

by lrh_0_2000 - C/C++ - 2005-09-09 17:49:32 阅读(861) 回复(5)

看到有些人对void指针不太清楚,我就试着解释一下,权当抛砖引玉。 大家都知道int *pint是定义了一个指针变量,这个变量里面放的是一个地址,而这个地址里面放的是一个int型的数值。char *pchar是定义了一个指针变量,这个变量里面放的是一个地址,而这个地址里面放的是一个char型的数值。 以此类推……我们也知道在32位计算机上,一般sizeof(pint)是4,也就是说指针变量p的大小是4个字节,每个地址用32位来表示。我们还...

by lenovo - C/C++ - 2003-12-19 16:30:52 阅读(3647) 回复(2)

Default constructor called. Default constructor called. Default constructor called. Default constructor called. Destructor called. Constructorl called. Destructor called. Constructor2 called. Destructor called. x=0,y=0 x=5,y=0 x=3,y=-858993460 Destructor called. Destructor called. Destructor called. Press any key to continue #include; class B { int x,y; public: B(); B(int i); B...

by 雪花啤酒 - C/C++ - 2003-12-11 11:00:37 阅读(456) 回复(0)

在头文件中。typedef void _void; extern int func(_void); 此时将报错,说_void的用法不正确。 而直接写 extern int func(void); 则正常。 g++ 4.2。 不知道为什么。 谢谢。

by Xorcerer - C/C++ - 2009-08-31 21:10:50 阅读(1468) 回复(9)

在linux中函数asmlinkage void __init start_kernel(void)申明的意思?

by sc_px_jiangyun - 内核/嵌入技术 - 2006-03-06 11:58:11 阅读(498) 回复(1)

一个低级的问题:如果函数的定义是:int checkpass(void);那么就说明调用这个函数时不用向其中传入任何参数了吧。 而(void*) a指的就是变量a的地址吧。 请问这么理解正确吗?谢谢各位的回答

by lmingcsce - C/C++ - 2009-08-28 00:48:39 阅读(816) 回复(3)

代码先上: stdafx.h -------------------------------------stdafx.h---------- #include #include #include #include #include #include #include #include #include using namespace std; class teststatic { public: int a; int b; teststatic(){} ~teststatic(){} void *fun(void *pvoid); create(); }; void *tests...

by lsupper - C/C++ - 2009-03-20 14:49:05 阅读(3491) 回复(11)

比如 [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 阅读(1029) 回复(7)

#include int main(void) { void* rval; rval = (void*)2; printf("%d\n", (int*)rval); printf("%d\n", (int)rval); printf("%d\n", *(int *)rval); return 0; } 运行的结果是: [zuhf@localhost thread]$ ./a.out 2 2 Segmentation fault 对这3条语句有点晕,哪位朋友能帮忙解释下这3条printf语句的不同? 我怎么觉得第3条才是对的阿?先强制转...

by xiaozhu2007 - C/C++ - 2007-10-19 08:53:25 阅读(1129) 回复(2)