diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..c11401d --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "c17", + "cppStandard": "c++98", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/HW9a.c b/HW9a.c index c2ad816..4b51d93 100644 --- a/HW9a.c +++ b/HW9a.c @@ -9,7 +9,6 @@ #include #include #include -#include // Globals to Simplify Passing Around // Contains pointer to queue memory diff --git a/HW9b.c b/HW9b.c index f809f16..6bcda59 100644 --- a/HW9b.c +++ b/HW9b.c @@ -9,7 +9,6 @@ #include #include #include -#include int ptr_size = 0; char* ptr; @@ -31,10 +30,6 @@ char pop() { void print() { for (int i = ptr_size - 1; i >= 0; i--) printf("%c\n",*(ptr+i)); - /* - for (int i = 0; i < ptr_size; i++) - printf((i + 1 != ptr_size)?"%c, ":"%c\n",*(ptr+i)); - */ } int main() { diff --git a/HW9c.c b/HW9c.c new file mode 100644 index 0000000..58a99d7 --- /dev/null +++ b/HW9c.c @@ -0,0 +1,27 @@ +/* + + COS135 - HW9c + Nicholas Pease + Reverse String + +*/ + +#include +#include +#include "PEASE.h" + +int main() { + printf("Reverse a phrase: "); + char input[20]; + fgets(input,20,stdin); + for (int i=0;i + +int ptr_size = 0; +char* ptr; + +void push(char addition) { + // Deal with allocation every time push is called and pop. If not initialized, the source is NULL + ptr = realloc((ptr_size == 0)? NULL: ptr, (ptr_size+1)*sizeof(char)); + *(ptr+ptr_size) = addition; + ptr_size++; +} + +char pop() { + char removal = *(ptr+ptr_size-1); + ptr_size--; + ptr = realloc((ptr_size == 0)? NULL: ptr, (ptr_size)*sizeof(char)); + return removal; +} + +#endif \ No newline at end of file diff --git a/a.out b/a.out index 83719ba..bb4761f 100755 Binary files a/a.out and b/a.out differ