// This program shows some different functions that you can use to help // you manipulate anything to do with strings. You can find these functions // in the standard library . The functions we will demonstrate here // are: strcpy (copy a string from one array to another - destination/source), // strlen(find length of a string), and // strcmp (compare two strings, return 0 if they are the same) // Sasha Vassar Week 5, Lecture 10 #include // Use the standard library for access to string functions #include #define MAX_LENGTH 15 int main (void) { //Declare an original array char word[MAX_LENGTH]; //Example using strcpy to copy from one string //to another (destination, source): strcpy(word, "Sasha"); printf("%s\n", word); //Example using strlen to find string length (returns int not including // '\0': int length = strlen("Sasha"); printf("The size of the string Sasha is: %d\n", length); //Example using strcmp to compare two strings character by character: //this function will return 0 if strings are equal //other int if not the same int compare_string1 = strcmp("Sasha", "Sashha"); printf("The two strings are the same: %d\n", compare_string1); compare_string1 = strcmp(word, "Sasha"); printf("The two strings are the same: %d\n", compare_string1); return 0; }