Permalink
Browse files

Sum of Pairs: C solutions by Hardy Jonck

  • Loading branch information...
1 parent 5fafbd7 commit f45740b177f11c00932ba2f9eeac737715205b49 Andreas Pauley committed Sep 18, 2009
Showing with 16 additions and 0 deletions.
  1. +16 −0 CodeSnippets/SumPairs/sumpairs-pointer.c
@@ -0,0 +1,16 @@
+// C solution by Hardy Jonck
+
+#include <stdio.h>
+#include <string.h>
+
+
+int main (int argc, const char * argv[]) {
+ int a[] = {1,2,3,4,5};
+ char items = sizeof(a)/sizeof(int);
+ int b[items];
+ int *c=b;
+ memcpy(&b,&a,items*sizeof(int));
+ while(c < &b[items-1]) { *c = *c + *(c+1);printf("%d\n",*c);c++;}
+
+ return 0;
+}

0 comments on commit f45740b

Please sign in to comment.