diff --git a/assignment7.txt b/assignment7.txt new file mode 100644 index 0000000..dff1563 --- /dev/null +++ b/assignment7.txt @@ -0,0 +1,18 @@ +Aly Milich + +1. ++*p and *++p both increment the value of the array that the pointer is pointing to whereas *p++ moves the pointer over. + +2. Left to right. + +3. Pointers make it easier to use arrays to change the values of certain spots. Since you don't need the for loop, it decreases the algorithmic complexity of your code and takes up less space in the computer & is easier to run. + +4.1 char array +4.2 Invalid -- "xyz" is not in the array +4.3 Invalid -- \0 will never equal 0 +4.4 Pointer +4.5 Address is 0 +4.6 pointer +4.7 Address is still 0 +4.8 Pointer +4.9 Invalid +4.10 5 diff --git a/pointers.c b/pointers.c new file mode 100644 index 0000000..d1aabd6 --- /dev/null +++ b/pointers.c @@ -0,0 +1,60 @@ +#include +#include + +char cat(char *a, char *b){ + char *point = a; + + while(*point != '\0'){ + point ++; + } + + while (*b!= '\0'){ + *point = *b; + point ++; + b++; + } + + +} + +char comp(char *c, char *d){ + + char string1[10]; + char string2[10]; + + *c = string1[10]; + *d = string2[10]; + + int i, length1, length2; + + length1 = strlen(string1); + length2 = strlen(string2); + + + for(i=0; length1 +#include + +int reverse(char arr[]){ + char *ptr1 = arr; + + char *ptr2 = ptr1 + strlen(arr) -1; + + int i; + + for(i=0; *ptr1!=*ptr2; i++){ + printf("%c", *ptr2); + --ptr2; + } +} + +int main(){ + + char string[] = "MILICH\0"; + + reverse(string); + + return 0; + +}