Skip to content

Commit

Permalink
Sum of Pairs: C solutions by Hardy Jonck
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Pauley committed May 27, 2010
1 parent 5fafbd7 commit f45740b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CodeSnippets/SumPairs/sumpairs-pointer.c
Original file line number Original file line Diff line number Diff line change
@@ -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.