Revision: 662
http://assorted.svn.sourceforge.net/assorted/?rev=662&view=rev
Author: yangzhang
Date: 2008-04-19 20:02:30 -0700 (Sat, 19 Apr 2008)
Log Message:
-----------
added voit pointer arith demo
Added Paths:
-----------
sandbox/trunk/src/c/voidptrs.c
Added: sandbox/trunk/src/c/voidptrs.c
===================================================================
--- sandbox/trunk/src/c/voidptrs.c (rev 0)
+++ sandbox/trunk/src/c/voidptrs.c 2008-04-20 03:02:30 UTC (rev 662)
@@ -0,0 +1,15 @@
+// Demonstrates that void pointer arithmetic works (they operate in bytes).
+
+#include <stdio.h>
+#include <strings.h>
+
+int
+main()
+{
+ char c[256] = "hello world";
+ void *p = c;
+ p += 5;
+ bzero(p, 10);
+ printf("%s\n", c);
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|