diff --git a/Assignment7.txt b/Assignment7.txt new file mode 100644 index 0000000..d80912e --- /dev/null +++ b/Assignment7.txt @@ -0,0 +1,19 @@ +Clarke Littlejohn + +1) if i recall correctly ++*P moves the pointer then gets the values, *p++ get the value in the point the increments it + and *++p is not an apoerator that works. + +2) I am confused by what this si asking it will go by what it is prendence so to will go from right to left or left to right based on the highest order + +3) you are working directly with the value so it is always modifing the number. + +4.1)string/char array/ +.2)invalid +.3)invalid +.4)pointer this gets the address of the array +.5)address this gets the address +.6)int this derefences the value +.7)pointer address p is pointer and ampersand gets the address +.8) this seems like incorrect syntax so it is invalid. +.9)invalid is invalid as main is a function and this should not work. +.10) it will return a value that is is 6 diff --git a/catcmp.c b/catcmp.c new file mode 100644 index 0000000..88e8d8c --- /dev/null +++ b/catcmp.c @@ -0,0 +1,59 @@ +#include + +int strcmp(char*,char*); +char* strct(char*,char*); + + + +int main(){ + + printf("\n"); + char *a = {"Hello"}; + char *b = {"World"}; + int aa=strcmp(a,b); + printf("%d",aa); + printf("\n"); + return 0; +} + +char * strct(char *one, char *two){ + char a[(sizeof(one)+sizeof(two)-4)]; + int i=0; + while(*one!='\0'){ + a[i]=*one; + one++; + i++; + } + while(*two!='\0'){ + a[i]=*two; + two++; + i++; + } + a[i]='\0'; + one=a; + return one; +} + + +int strcmp(char* one,char* two){ + + while(*one==*two){ + one++; + two++; + } + return ((int)(*one)-(int)(*two)); +} + + + + + + + + + + + + + + diff --git a/reverse.c b/reverse.c new file mode 100644 index 0000000..9da0e7f --- /dev/null +++ b/reverse.c @@ -0,0 +1,37 @@ +//Clarke Littlejohn +//reverse.c +// i had no idea how to use the second pointer, it seems useless to me as i just used a tracker it see how far +//away the end was from the start + +#include + + +void reverse(char[]); + +int main(){ + + char str1[100]; + + printf("Enter in a word."); + fgets(str1,sizeof(str1),stdin); + reverse(str1); + +} + + +void reverse(char str1[]){ + + int tracker = 0; + char* pStr=str1; + char* pStr2; + char start = *pStr; + while(*pStr!='\n'){pStr++;tracker++; } + *pStr='\0'; + printf("%s\n",str1); + for(;tracker>0;tracker--){ + pStr--; + printf("%c",*pStr); + } + + +}