Good Stopping point for CS480 Prep
++ Phases 1-6 Preparation ++ C, H, Makefiles
This commit is contained in:
parent
b861b15368
commit
ca321e6c4e
19 changed files with 889 additions and 0 deletions
163
Preparation/Phase6/StringUtils.c
Normal file
163
Preparation/Phase6/StringUtils.c
Normal file
|
|
@ -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
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue