From ca321e6c4eff47acf968a6c865f622367ef51abc Mon Sep 17 00:00:00 2001 From: cdez Date: Sat, 6 Jan 2024 21:56:16 -0700 Subject: [PATCH] Good Stopping point for CS480 Prep ++ Phases 1-6 Preparation ++ C, H, Makefiles --- Preparation/CS480_Prep.c | 83 +++++++++++++ Preparation/CS480_Prep.h | 35 ++++++ Preparation/Makefile | 28 +++++ Preparation/Phase4/Makefile | 28 +++++ Preparation/Phase4/Phase4_Prep.c | 66 ++++++++++ Preparation/Phase4/Phase4_Prep.h | 22 ++++ Preparation/Phase4/StandardConstants.h | 73 +++++++++++ Preparation/Phase5/Makefile | 28 +++++ Preparation/Phase5/Phase5_Prep.c | 32 +++++ Preparation/Phase5/Phase5_Prep.h | 11 ++ Preparation/Phase5/StandardConstants.h | 73 +++++++++++ Preparation/Phase5/StringUtils.c | 32 +++++ Preparation/Phase5/StringUtils.h | 28 +++++ Preparation/Phase6/Makefile | 28 +++++ Preparation/Phase6/Phase6_Prep.c | 47 +++++++ Preparation/Phase6/Phase6_Prep.h | 11 ++ Preparation/Phase6/StandardConstants.h | 73 +++++++++++ Preparation/Phase6/StringUtils.c | 163 +++++++++++++++++++++++++ Preparation/Phase6/StringUtils.h | 28 +++++ 19 files changed, 889 insertions(+) create mode 100644 Preparation/CS480_Prep.c create mode 100644 Preparation/CS480_Prep.h create mode 100644 Preparation/Makefile create mode 100644 Preparation/Phase4/Makefile create mode 100644 Preparation/Phase4/Phase4_Prep.c create mode 100644 Preparation/Phase4/Phase4_Prep.h create mode 100644 Preparation/Phase4/StandardConstants.h create mode 100644 Preparation/Phase5/Makefile create mode 100644 Preparation/Phase5/Phase5_Prep.c create mode 100644 Preparation/Phase5/Phase5_Prep.h create mode 100644 Preparation/Phase5/StandardConstants.h create mode 100644 Preparation/Phase5/StringUtils.c create mode 100644 Preparation/Phase5/StringUtils.h create mode 100644 Preparation/Phase6/Makefile create mode 100644 Preparation/Phase6/Phase6_Prep.c create mode 100644 Preparation/Phase6/Phase6_Prep.h create mode 100644 Preparation/Phase6/StandardConstants.h create mode 100644 Preparation/Phase6/StringUtils.c create mode 100644 Preparation/Phase6/StringUtils.h diff --git a/Preparation/CS480_Prep.c b/Preparation/CS480_Prep.c new file mode 100644 index 0000000..e1046cf --- /dev/null +++ b/Preparation/CS480_Prep.c @@ -0,0 +1,83 @@ +// header files +#include +#include +#include +#include + +// constants + +/* +Name: add_two_nums +Process: adds two numbers together given user input +Function input/parameters: NONE +Function output/parameters: NONE +Function output/returned: NONE +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int add_two_nums() +{ + // define variables + int first_num, second_num, total; + // get user input + printf("---Adding two numbers---\nPlease enter two numbers(space in between): "); + scanf("%d %d", &first_num, &second_num); + // do calculations + total = first_num + second_num; + // display results + printf("\n%d + %d = %d!", first_num, second_num, total); + // return success + return 0; +} + +/* +Name: add_two_nums_parameterized +Process: adds two numbers together given user input as parameters +Function input/parameters: +Function output/parameters: NONE +Function output/returned: NONE +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int add_two_nums_parameterized(int first_num, int second_num) +{ + // define variables + int total; + // get user input + printf("---Adding two numbers PARAMETERIZED!---\n"); + // do calculations + total = first_num + second_num; + // display results + printf("\n%d + %d = %d!", first_num, second_num, total); + // return total + return total; +} + +/* +Name: main +Process: Runs all the functions listed above that was used as preparation for + CS480. Videos were used as the similar practice. +Function input/parameters: NONE +Function output/parameters: NONE +Function output/returned: NONE +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int main() +{ + // define/initialize variables + int tnNum1, tnNum2, tnSum; + // get user input + printf("Please input numbers for the parameterized version of adding two numbers.\n"); + scanf("%d", &tnNum1); + scanf("%d", &tnNum2); + // do calculations + add_two_nums(); + tnSum = add_two_nums_parameterized(tnNum1, tnNum2); + // display results + // return success + return 0; +} \ No newline at end of file diff --git a/Preparation/CS480_Prep.h b/Preparation/CS480_Prep.h new file mode 100644 index 0000000..80294fa --- /dev/null +++ b/Preparation/CS480_Prep.h @@ -0,0 +1,35 @@ +#ifndef CS480PREP +#define CS480PREP + +// header files + +// data structures + +// function headers + +/* +Name: add_two_nums +Process: adds two numbers together given user input +Function input/parameters: NONE +Function output/parameters: NONE +Function output/returned: NONE +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int add_two_nums(); + +/* +Name: add_two_nums_parameterized +Process: adds two numbers together given user input as parameters +Function input/parameters: int first_num, + int second_num +Function output/parameters: int sum +Function output/returned: NONE +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int add_two_nums_parameterized(int first_num, int second_num); + +#endif // CS480PREP \ No newline at end of file diff --git a/Preparation/Makefile b/Preparation/Makefile new file mode 100644 index 0000000..aebfc2c --- /dev/null +++ b/Preparation/Makefile @@ -0,0 +1,28 @@ +CC = gcc -Wall +SOURCES = CS480_Prep.c +OBJECTS = CS480_Prep.o + +# Uses the template structure defined in the TypicalUtils folder + +all: CS480_Prep + +CS480_Prep: $(OBJECTS) + $(CC) $(OBJECTS) -o CS480_Prep + +CS480_Prep.o: CS480_Prep.c + $(CC) -c CS480_Prep.c -o CS480_Prep.o + +#GeneralUtility.o: GeneralUtility.c +# $(CC) -c GeneralUtility.c -o GeneralUtility.o + +clean: + rm -f $(OBJECTS) CS480_Prep CS480_Prep.out + +clean_objects: + rm -f $(OBJECTS) + +run: + ./CS480_Prep + +run_win: + CS480_Prep diff --git a/Preparation/Phase4/Makefile b/Preparation/Phase4/Makefile new file mode 100644 index 0000000..eb5e146 --- /dev/null +++ b/Preparation/Phase4/Makefile @@ -0,0 +1,28 @@ +CC = gcc -Wall +SOURCES = Phase4_Prep.c +OBJECTS = Phase4_Prep.o + +# Uses the template structure defined in the TypicalUtils folder + +all: Phase4_Prep + +Phase4_Prep: $(OBJECTS) + $(CC) $(OBJECTS) -o Phase4_Prep + +Phase4_Prep.o: Phase4_Prep.c + $(CC) -c Phase4_Prep.c -o Phase4_Prep.o + +#GeneralUtility.o: GeneralUtility.c +# $(CC) -c GeneralUtility.c -o GeneralUtility.o + +clean: + rm -f $(OBJECTS) Phase4_Prep Phase4_Prep.out + +clean_objects: + rm -f $(OBJECTS) + +run: + ./Phase4_Prep + +run_win: + Phase4_Prep diff --git a/Preparation/Phase4/Phase4_Prep.c b/Preparation/Phase4/Phase4_Prep.c new file mode 100644 index 0000000..650fbe3 --- /dev/null +++ b/Preparation/Phase4/Phase4_Prep.c @@ -0,0 +1,66 @@ +// header files +#include +#include +#include +#include +#include "StandardConstants.h" + +// constants + +// function implementations + +/* +Name: getStringLength +Process: gets length of string from start to NULL_CHAR ('\0') +Function input/parameters: c-style string (char *) +Function output/parameters: NONE +Function output/returned: length of string (int) +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int getStringLength(const char *stringIn) +{ + // define variables + int stringLength = 0, currentCharacter = 0; + // get user input (not needed) + // do calculations + while(currentCharacter < STD_STR_LEN && stringIn[currentCharacter] != NULL_CHAR) + { + // increment string length + stringLength = stringLength + 1; + // increment currentCharacter + currentCharacter = currentCharacter + 1; + } + // display results (not needed) + // return success + return stringLength; +} + +/* +Name: main +Process: Runs all the functions listed above that was used as preparation for + CS480. Videos were used as the similar practice. +Function input/parameters: NONE +Function output/parameters: NONE +Function output/returned: NONE +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int main() +{ + // define/initialize variables + int stringLen = 0; + char newString[] = "This is my new string!!!"; + printf("\n---Phase 4: Getting String Length---\n"); + printf("====================================\n"); + // get user input + // do calculations + stringLen = getStringLength(newString); + // display results + printf("\nThe length of string '%s' is %d.\n", newString, stringLen); + printf("\nProgram End\n"); + // return success + return 0; +} \ No newline at end of file diff --git a/Preparation/Phase4/Phase4_Prep.h b/Preparation/Phase4/Phase4_Prep.h new file mode 100644 index 0000000..423f5e1 --- /dev/null +++ b/Preparation/Phase4/Phase4_Prep.h @@ -0,0 +1,22 @@ +#ifndef CS480PREP +#define CS480PREP + +// header files + +// data structures + +// function prototypes + +/* +Name: getStringLength +Process: counts length of string from start to NULL_CHAR ('\0') +Function input/parameters: c-style string (char *) +Function output/parameters: NONE +Function output/returned: length of string (int) +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int getStringLength(const char *stringLen); + +#endif // CS480PREP \ No newline at end of file diff --git a/Preparation/Phase4/StandardConstants.h b/Preparation/Phase4/StandardConstants.h new file mode 100644 index 0000000..e536c24 --- /dev/null +++ b/Preparation/Phase4/StandardConstants.h @@ -0,0 +1,73 @@ +// Preprocessor directives +#ifndef STANDARD_CONSTANTS_H +#define STANDARD_CONSTANTS_H + +// Include Boolean +#include + +// global constants + +// constant for end of c-string null character +#define CARRIAGE_RETURN_CHAR '\r' + +//constant for a COLON +#define COLON ':' + +//constant for a COMMA +#define COMMA ',' + +//Constant to print a dash +#define DASH '-' + +// highest printable character +#define HIGHEST_PRINTABLE_CHAR '~' + +// constant for huge string length +#define HUGE_STR_LEN 256 + +// lowest printable character +#define LOWEST_PRINTABLE_CHAR ' ' + +// constant for small string length +#define MIN_STR_LEN 32 + +// constant for maximum string length +#define MAX_STR_LEN 128 + +// constant for end of c-string null character +#define NEWLINE_CHAR '\n' + +// first non-printable above ASCII +#define DELETE_KEY 127 + +// constant for end of c-string null character +#define NULL_CHAR '\0' + +// columns found in grade sheet before grading columns +#define NUM_BASE_COLS 5 + +// constant for number of grading frequency bins +#define NUM_FREQUENCY_BINS 10 + +//Constant for printing a pipe +#define PIPE '|' + +//Constant for a period +#define PERIOD '.' + +//Constant for PRECISION, 2 digits +#define PRECISION_2 2 + +//Constant for PRECISION, 4 digits +#define PRECISION_4 4 + +// constant for space character +#define SPACE ' ' + +// constant for standard string length +#define STD_STR_LEN 64 + +// constant for smallest string length +#define TINY_STR_LEN 16 + +#endif // STANDARD_CONSTANTS diff --git a/Preparation/Phase5/Makefile b/Preparation/Phase5/Makefile new file mode 100644 index 0000000..7be54e9 --- /dev/null +++ b/Preparation/Phase5/Makefile @@ -0,0 +1,28 @@ +CC = gcc -Wall +SOURCES = Phase5_Prep.c StringUtils.c +OBJECTS = Phase5_Prep.o StringUtils.o + +# Uses the template structure defined in the TypicalUtils folder + +all: Phase5_Prep + +Phase5_Prep: $(OBJECTS) + $(CC) $(OBJECTS) -o Phase5_Prep + +Phase5_Prep.o: Phase5_Prep.c + $(CC) -c Phase5_Prep.c -o Phase5_Prep.o + +StringUtils.o: StringUtils.c + $(CC) -c StringUtils.c -o StringUtils.o + +clean: + rm -f $(OBJECTS) Phase5_Prep Phase5_Prep.out + +clean_objects: + rm -f $(OBJECTS) + +run: + ./Phase5_Prep + +run_win: + Phase5_Prep diff --git a/Preparation/Phase5/Phase5_Prep.c b/Preparation/Phase5/Phase5_Prep.c new file mode 100644 index 0000000..47f9815 --- /dev/null +++ b/Preparation/Phase5/Phase5_Prep.c @@ -0,0 +1,32 @@ +// header files +#include "StringUtils.h" + +// constants + +/* +Name: main +Process: Runs all the functions listed above that was used as preparation for + CS480. Videos were used as the similar practice. +Function input/parameters: NONE +Function output/parameters: NONE +Function output/returned: NONE +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int main() +{ + // define/initialize variables + int stringLen = 0; + char newString[] = "This is my new string!!!"; + printf("\n---Phase 5: Getting String Length---\n"); + printf("====================================\n"); + // get user input + // do calculations + stringLen = getStringLength(newString); + // display results + printf("\nThe length of string '%s' is %d.\n", newString, stringLen); + printf("\nProgram End\n"); + // return success + return 0; +} \ No newline at end of file diff --git a/Preparation/Phase5/Phase5_Prep.h b/Preparation/Phase5/Phase5_Prep.h new file mode 100644 index 0000000..4bf5d3f --- /dev/null +++ b/Preparation/Phase5/Phase5_Prep.h @@ -0,0 +1,11 @@ +#ifndef PHASE5PREP +#define PHASE5PREP + +// header files +#include "StringUtils.h" + +// data structures + +// function prototypes + +#endif // PHASE5PREP \ No newline at end of file diff --git a/Preparation/Phase5/StandardConstants.h b/Preparation/Phase5/StandardConstants.h new file mode 100644 index 0000000..e536c24 --- /dev/null +++ b/Preparation/Phase5/StandardConstants.h @@ -0,0 +1,73 @@ +// Preprocessor directives +#ifndef STANDARD_CONSTANTS_H +#define STANDARD_CONSTANTS_H + +// Include Boolean +#include + +// global constants + +// constant for end of c-string null character +#define CARRIAGE_RETURN_CHAR '\r' + +//constant for a COLON +#define COLON ':' + +//constant for a COMMA +#define COMMA ',' + +//Constant to print a dash +#define DASH '-' + +// highest printable character +#define HIGHEST_PRINTABLE_CHAR '~' + +// constant for huge string length +#define HUGE_STR_LEN 256 + +// lowest printable character +#define LOWEST_PRINTABLE_CHAR ' ' + +// constant for small string length +#define MIN_STR_LEN 32 + +// constant for maximum string length +#define MAX_STR_LEN 128 + +// constant for end of c-string null character +#define NEWLINE_CHAR '\n' + +// first non-printable above ASCII +#define DELETE_KEY 127 + +// constant for end of c-string null character +#define NULL_CHAR '\0' + +// columns found in grade sheet before grading columns +#define NUM_BASE_COLS 5 + +// constant for number of grading frequency bins +#define NUM_FREQUENCY_BINS 10 + +//Constant for printing a pipe +#define PIPE '|' + +//Constant for a period +#define PERIOD '.' + +//Constant for PRECISION, 2 digits +#define PRECISION_2 2 + +//Constant for PRECISION, 4 digits +#define PRECISION_4 4 + +// constant for space character +#define SPACE ' ' + +// constant for standard string length +#define STD_STR_LEN 64 + +// constant for smallest string length +#define TINY_STR_LEN 16 + +#endif // STANDARD_CONSTANTS diff --git a/Preparation/Phase5/StringUtils.c b/Preparation/Phase5/StringUtils.c new file mode 100644 index 0000000..076c600 --- /dev/null +++ b/Preparation/Phase5/StringUtils.c @@ -0,0 +1,32 @@ +// header files +#include "StringUtils.h" + +// function implementations + +/* +Name: getStringLength +Process: gets length of string from start to NULL_CHAR ('\0') +Function input/parameters: c-style string (char *) +Function output/parameters: NONE +Function output/returned: length of string (int) +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int getStringLength(const char *stringIn) +{ + // define variables + int stringLength = 0, currentCharacter = 0; + // get user input (not needed) + // do calculations + while (currentCharacter < STD_STR_LEN && stringIn[currentCharacter] != NULL_CHAR) + { + // increment string length + stringLength = stringLength + 1; + // increment currentCharacter + currentCharacter = currentCharacter + 1; + } + // display results (not needed) + // return success + return stringLength; +} \ No newline at end of file diff --git a/Preparation/Phase5/StringUtils.h b/Preparation/Phase5/StringUtils.h new file mode 100644 index 0000000..1fc2f42 --- /dev/null +++ b/Preparation/Phase5/StringUtils.h @@ -0,0 +1,28 @@ +#ifndef STRINGUTILSPREP +#define STRINGUTILSPREP + +// header files +#include +#include +#include +#include +#include +#include "StandardConstants.h" + +// data structures + +// function prototypes + +/* +Name: getStringLength +Process: counts length of string from start to NULL_CHAR ('\0') +Function input/parameters: c-style string (char *) +Function output/parameters: NONE +Function output/returned: length of string (int) +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int getStringLength(const char *stringLen); + +#endif // STRINGUTILSPREP \ No newline at end of file diff --git a/Preparation/Phase6/Makefile b/Preparation/Phase6/Makefile new file mode 100644 index 0000000..35af769 --- /dev/null +++ b/Preparation/Phase6/Makefile @@ -0,0 +1,28 @@ +CC = gcc -Wall +SOURCES = Phase6_Prep.c StringUtils.c +OBJECTS = Phase6_Prep.o StringUtils.o + +# Uses the template structure defined in the TypicalUtils folder + +all: Phase6_Prep + +Phase6_Prep: $(OBJECTS) + $(CC) $(OBJECTS) -o Phase6_Prep + +Phase6_Prep.o: Phase6_Prep.c + $(CC) -c Phase6_Prep.c -o Phase6_Prep.o + +StringUtils.o: StringUtils.c + $(CC) -c StringUtils.c -o StringUtils.o + +clean: + rm -f $(OBJECTS) Phase6_Prep Phase6_Prep.out + +clean_objects: + rm -f $(OBJECTS) + +run: + ./Phase6_Prep + +run_win: + Phase6_Prep diff --git a/Preparation/Phase6/Phase6_Prep.c b/Preparation/Phase6/Phase6_Prep.c new file mode 100644 index 0000000..60d0ea3 --- /dev/null +++ b/Preparation/Phase6/Phase6_Prep.c @@ -0,0 +1,47 @@ +// header files +#include "StringUtils.h" + +// constants + +/* +Name: main +Process: Runs the String Utilities +Function input/parameters: NONE +Function output/parameters: NONE +Function output/returned: NONE +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int main() +{ + // define/initialize variables + printf("\n---Phase 6: All String Utilities---\n"); + printf("=====================================\n"); + // get user input + // do calculations + + // string length + // getStringLength + // string copy + // copyString + // string concatenate + // catString + // string compare (<, >, =) + // compareString + // string substring get + // substringGet + // string substring find + // substringFind + // string set to lower + // lowerString + // string get to delimiter + // stringDelimiter + // string get to end of line + // stringEOL + + // display results + printf("\nProgram End\n"); + // return success + return 0; +} \ No newline at end of file diff --git a/Preparation/Phase6/Phase6_Prep.h b/Preparation/Phase6/Phase6_Prep.h new file mode 100644 index 0000000..812df75 --- /dev/null +++ b/Preparation/Phase6/Phase6_Prep.h @@ -0,0 +1,11 @@ +#ifndef PHASE6PREP +#define PHASE6PREP + +// header files +#include "StringUtils.h" + +// data structures + +// function prototypes + +#endif // PHASE6PREP \ No newline at end of file diff --git a/Preparation/Phase6/StandardConstants.h b/Preparation/Phase6/StandardConstants.h new file mode 100644 index 0000000..e536c24 --- /dev/null +++ b/Preparation/Phase6/StandardConstants.h @@ -0,0 +1,73 @@ +// Preprocessor directives +#ifndef STANDARD_CONSTANTS_H +#define STANDARD_CONSTANTS_H + +// Include Boolean +#include + +// global constants + +// constant for end of c-string null character +#define CARRIAGE_RETURN_CHAR '\r' + +//constant for a COLON +#define COLON ':' + +//constant for a COMMA +#define COMMA ',' + +//Constant to print a dash +#define DASH '-' + +// highest printable character +#define HIGHEST_PRINTABLE_CHAR '~' + +// constant for huge string length +#define HUGE_STR_LEN 256 + +// lowest printable character +#define LOWEST_PRINTABLE_CHAR ' ' + +// constant for small string length +#define MIN_STR_LEN 32 + +// constant for maximum string length +#define MAX_STR_LEN 128 + +// constant for end of c-string null character +#define NEWLINE_CHAR '\n' + +// first non-printable above ASCII +#define DELETE_KEY 127 + +// constant for end of c-string null character +#define NULL_CHAR '\0' + +// columns found in grade sheet before grading columns +#define NUM_BASE_COLS 5 + +// constant for number of grading frequency bins +#define NUM_FREQUENCY_BINS 10 + +//Constant for printing a pipe +#define PIPE '|' + +//Constant for a period +#define PERIOD '.' + +//Constant for PRECISION, 2 digits +#define PRECISION_2 2 + +//Constant for PRECISION, 4 digits +#define PRECISION_4 4 + +// constant for space character +#define SPACE ' ' + +// constant for standard string length +#define STD_STR_LEN 64 + +// constant for smallest string length +#define TINY_STR_LEN 16 + +#endif // STANDARD_CONSTANTS diff --git a/Preparation/Phase6/StringUtils.c b/Preparation/Phase6/StringUtils.c new file mode 100644 index 0000000..4474bff --- /dev/null +++ b/Preparation/Phase6/StringUtils.c @@ -0,0 +1,163 @@ +// header files +#include "StringUtils.h" + +// list of utils: + // string length + // getStringLength + // string copy + // copyString + // string concatenate + // catString + // string compare (<, >, =) + // compareString + // string substring get + // getSubString + // string substring find + // findSubString + // string set to lower + // lowerString + // string get to delimiter + // stringDelimiter + // string get to end of line + // stringEOL + +// function implementations + +/* +Name: catString +Process: concatenates two strings +Function input/parameters: c-style string (char *) +Function output/parameters: c-style string (char *) +Function output/returned: NONE +Device input/---: NONE +Device output/---: NONE +Dependencies: getStringLength +*/ +void catString(char *outString, const char *inString) +{ + // no return, void. +} + +/* +Name: compareString +Process: compares two strings as follows: + - if left string is alphabetically greater than the right string, + returns value greater than zero + - if left string is alphabetically less than the right string, + returns value less than zero + - if strings are alphabetically equal but one is longer, + longer one is greater + - otherwise, returns zero +Function input/parameters: c-style strings (char *) [first and second/left&right] +Function output/parameters: NONE +Function output/returned: results as specfifed above (int) +Device input/---: NONE +Device output/---: NONE +Dependencies: getStringLength +*/ +int compareString(const char *firstString, const char *secondString) +{ + // return zero (temp) + return 0; +} + +/* +Name: copyString +Process: copies string into new string variable, overwrites destination. +Function input/parameters: c-style string (char *) +Function output/parameters: c-style string (char *) +Function output/returned: NONE +Device input/---: NONE +Device output/---: NONE +Dependencies: getStringLength +*/ +void copyString(char *outString, const char *inString) +{ + // no return, void. +} + +/* +Name: getStringLength +Process: gets length of string from start to NULL_CHAR ('\0') +Function input/parameters: c-style string (char *) +Function output/parameters: NONE +Function output/returned: length of string (int) +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int getStringLength(const char *stringIn) +{ + // define variables + int stringLength = 0, currentCharacter = 0; + // get user input (not needed) + // do calculations + while (currentCharacter < STD_STR_LEN && stringIn[currentCharacter] != NULL_CHAR) + { + // increment string length + stringLength = stringLength + 1; + // increment currentCharacter + currentCharacter = currentCharacter + 1; + } + // display results (not needed) + // return success + return stringLength; +} + +/* +Name: getSubString +Process: captures sub string within larger string + between two inclusive indices. + returns empty string if either index is out of range, + assumes enough memory in dest string +Function input/parameters: ??? +Function output/parameters: NONE +Function output/returned: ??? +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ + +/* +Name: findSubString +Process: ??? +Function input/parameters: ??? +Function output/parameters: NONE +Function output/returned: ??? +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ + +/* +Name: ??? +Process: ??? +Function input/parameters: ??? +Function output/parameters: NONE +Function output/returned: ??? +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ + +/* +Name: ??? +Process: ??? +Function input/parameters: ??? +Function output/parameters: NONE +Function output/returned: ??? +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ + +/* +Name: ??? +Process: ??? +Function input/parameters: ??? +Function output/parameters: NONE +Function output/returned: ??? +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ \ No newline at end of file diff --git a/Preparation/Phase6/StringUtils.h b/Preparation/Phase6/StringUtils.h new file mode 100644 index 0000000..1fc2f42 --- /dev/null +++ b/Preparation/Phase6/StringUtils.h @@ -0,0 +1,28 @@ +#ifndef STRINGUTILSPREP +#define STRINGUTILSPREP + +// header files +#include +#include +#include +#include +#include +#include "StandardConstants.h" + +// data structures + +// function prototypes + +/* +Name: getStringLength +Process: counts length of string from start to NULL_CHAR ('\0') +Function input/parameters: c-style string (char *) +Function output/parameters: NONE +Function output/returned: length of string (int) +Device input/---: NONE +Device output/---: NONE +Dependencies: included by standard libraries +*/ +int getStringLength(const char *stringLen); + +#endif // STRINGUTILSPREP \ No newline at end of file