Question
How do you do the SwapStringsAlt function? It is another version of the swap string function for the 2D array. #define NUM_STRINGS 4 #define STRING_LENGTH
How do you do the SwapStringsAlt function? It is another version of the swap string function for the 2D array.
#define NUM_STRINGS 4
#define STRING_LENGTH 32
// Forward Declarations
void initializeStrings(char[NUM_STRINGS][STRING_LENGTH]);
void reverseString(char strings[NUM_STRINGS][STRING_LENGTH]);
void encryptStrings(char[NUM_STRINGS][STRING_LENGTH], int);
void decryptStrings(char[NUM_STRINGS][STRING_LENGTH], int);
void swapStrings(char[STRING_LENGTH], char[STRING_LENGTH]);
void sortStrings(char[NUM_STRINGS][STRING_LENGTH]);
void printStrings(char[NUM_STRINGS][STRING_LENGTH]);
void reversePrint(char[NUM_STRINGS][STRING_LENGTH]);
void initializeStrings(char strings[NUM_STRINGS][STRING_LENGTH])
{
for (int i = 0; i < NUM_STRINGS; i++) {
for (int f = 0; f < STRING_LENGTH; f++) {
strings[i][f] = '\0';
}
}
}
void swapStrings(char string1[STRING_LENGTH], char string2[STRING_LENGTH])
{
char temporary[STRING_LENGTH];
stringcopy(temporary, string1);
stringcopy(string1, string2);
stringcopy(string2, temporary);
}
// The following solution is also correct:
void swapStringsAlt(char *string1, char *string2)
{
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started