diff --git a/assignment7.txt b/assignment7.txt new file mode 100644 index 0000000..a2edf6e --- /dev/null +++ b/assignment7.txt @@ -0,0 +1,22 @@ + + +1. ++*p increments what the pointer points to whereas the *p++ actually increases the value of the pointer. *++p is also increases what the pointer points to. + + +2. Oh the left is guaanteed because its higher in the order of operations. + + +3. pointers allow easier use with arrays. You can go through the pointer without the for loop and it allows easier access outside of the main function. + + +4.1 char array +4.2 Invalid becaus xyz in quotes is not an arry +4.3 Invalid becuse that will never be true +4.4 pointer +4.5 address is 0 +4.6 pointer +4.7 adress is 0 becuase we haven't moved it anywhere only increased the value at a point +4.8 A pointer +4.9 Invalid, you can access main like that because it isn't a pointer +4.10 5 +I don't want to edit this now that we're going over it, but I just didn't understand what the questions were asking.... diff --git a/point b/point new file mode 100755 index 0000000..0399bc3 Binary files /dev/null and b/point differ diff --git a/point.c b/point.c new file mode 100644 index 0000000..63a451c --- /dev/null +++ b/point.c @@ -0,0 +1,65 @@ +#include +#include + +char cat(char *a, char *b){ + char *point = a; + + while(*point != '\0'){ + point++; + + } + + while(*b != '\0'){ + *point = *b; + point++; + b++; + + } + + +} + +char compare(char *c, char *d){ + char string1[10]; + char string2[10]; + + *c = string1[10]; + *d = string2[10]; + + int i, len1, len2; + + len1 = strlen(string1); + + len2 = strlen(string2); + + for(i=0; len1<=len2; i++){ + + if(string1[i] == string2[i]){ + + printf("0"); + i++; + } + + else{ + printf("1"); + break; + + } + + + } +} + + +int main(){ + char a[] = "Emma"; + char b[] = "Ladouceur"; + cat(a, b); + printf("%s\n", a); + char c[]="Emma"; + char d[]="Emma"; + + compare(c,d); + return 0; + +} diff --git a/reverse b/reverse new file mode 100755 index 0000000..6832375 Binary files /dev/null and b/reverse differ diff --git a/reverse.c b/reverse.c new file mode 100644 index 0000000..0c6014c --- /dev/null +++ b/reverse.c @@ -0,0 +1,35 @@ +//Emma Ladouceur + + +#include +#include + + +int reverse(char arr[]){ + + + char *ptrStart = arr; + + char *ptrEnd = ptrStart + strlen(arr)-1; + + int i; + for(i=0; *ptrStart != *ptrEnd; i++){ + printf("%c", *ptrEnd); + --ptrEnd; + + } + +} +int main(){ + printf("Enter a string of no more than 100 letters\n"); + char string[100]; + fgets(string, sizeof(string), stdin); + reverse(string); + + + +return 0; + + + +}