// header files #include "StringUtils.h" //////////////////////////////////////////////////////////////////////////////// // Main program /* * Name: main * Process: Finds the length of a string and displays it * Function Input/Parameters: None * Function Output/Parameters: None * Function Output/Returned: Function / Program success (0) * Device Input / Keyboard: None * Device Output / Monitor: Result displayed * Dependencies: stdio tools */ int main() { // initialize function/variables // create test strings char testString[] = "This is a really cool string!"; char otherString[ MAX_STR_LEN ]; char subString[ MAX_STR_LEN ]; char lowerCaseString[ MAX_STR_LEN ]; char captureString[ MAX_STR_LEN ]; // declare other variables int strLen, subStrStart; // display title // function: printf printf( "\nString Length Test Program\n" ); printf( "==========================\n\n" ); // conduct string length test // function: getStringLength strLen = getStringLength( testString ); // display result to user // function: printf printf( "The length of string \'%s\' is %d\n\n", testString, strLen ); // test copy string function // function: copyString copyString( otherString, testString ); // display copy test to user // function: printf printf( "Copied string is: %s\n\n", otherString ); // test concatenate string function // function: concatenateString concatenateString( otherString, " I'm pretty sure of it." ); // display concatenate test to user // function: printf printf( "Concatenated string is: %s\n\n", otherString ); // test compare string function for greater than condition // function: compareString if( compareString( "Sally", "Roger" ) > STR_EQ ) { // display compare/greater than test to user // function: printf printf( "\'Sally\' is greater than \'Roger\'\n\n" ); } // test compare string function for less than condition // function: compareString if( compareString( "Cindi", "Sally" ) < STR_EQ ) { // display compare/less than test to user // function: printf printf( "\'Cindi\' is less than \'Sally\'\n\n" ); } // test compare string function for equals condition // function: compareString if( compareString( "Benedict Cumberbatch", "Benedict Cumberbatch" ) == STR_EQ ) { // display compare/equals test to user // function: printf printf( "\'Benedict Cumberbatch\' is equal to \'Benedict Cumberbatch\'\n\n" ); } // test get sub string function // function: getSubString getSubString( subString, otherString, 34, 44 ); // display get sub string test to user // function: printf printf( "Sub string found: %s\n\n", subString ); // test find sub string function // function: findSubString subStrStart = findSubString( otherString, "pretty sure" ); // display find sub string test to user // function: printf printf( "Sub string start: %d\n\n", subStrStart ); // test for setting string with any upper case letter(s) to lower case // function: setStrToLowerCase setStrToLowerCase( lowerCaseString, otherString ); // display lower case string result to user // function: printf printf( "Lower case string: %s\n\n", lowerCaseString ); // test get line to delimiter // function: getStringToDelimiter getStringToDelimiter( stdin, '.', captureString ); // stdin is a file pointer // display get line to delimiter string result to user // function: printf printf( "Captured to delimiter: %s\n\n", captureString ); // test get line to end of line // function: getStringToLineEnd getStringToLineEnd( stdin, captureString ); // display get line to line end result to user // function: printf printf( "Captured to end of line : %s\n\n", captureString ); // shut down program // display program end // return program success return 0; }