From 9aef0df07636a23eb6b5c20b06b4b8c5cee2abe6 Mon Sep 17 00:00:00 2001 From: cmg2213 Date: Mon, 11 Jul 2016 09:56:39 -0400 Subject: [PATCH] Add files via upload --- homework7 | 30 ++++++++++++++++++++++++++++++ swap2.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 homework7 create mode 100644 swap2.c diff --git a/homework7 b/homework7 new file mode 100644 index 0000000..93fcb25 --- /dev/null +++ b/homework7 @@ -0,0 +1,30 @@ +Caleb Gershengorn + +1: +++*p:advances the pointer one space in the array in memory, than checks what is in that spot. +*p++: checks the space in memory at that spot, then advances one space. +*++p" does the same as the first, because the placement of the '++' makes the difference, not the '*' + +2: +Left to right garuntees operator precedence. + +3: +Using pointers allows you to more easily look through lists and access things in memory than having to reference them directly. + +4: +int *p=12 +*p=2 +char + +4.1--valid +4.2--invalid(dash is not a thing) +4.3--valid(just false) +4.4--valid(dereference operator) +4.5--valid(stores a value at a[0]) +4.6--valid(dereference operator) +4.7--valid(stores value at p) +4.8--invalid +4.9--invalid(main is a special use function) +4.10--valid + + diff --git a/swap2.c b/swap2.c new file mode 100644 index 0000000..127d5fe --- /dev/null +++ b/swap2.c @@ -0,0 +1,38 @@ +#include +#include + +void swap(char*word,int sizeWord){ + int i; + int j; + char * wordPtr=word; + if (sizeWord%2==0) + { + for (i=0;i