CS480-Projects/Preparation/Phase5/StringUtils.c
cdez ca321e6c4e Good Stopping point for CS480 Prep
++ Phases 1-6 Preparation
++ C, H, Makefiles
2024-01-06 21:56:16 -07:00

32 lines
No EOL
905 B
C

// 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;
}