Question: C PROGRAM help Add and test a function swapStrings that will swap two strings. DO NOT use strcpy . The characters comprising the strings do
Add and test a function swapStrings that will swap two strings.
DO NOT use strcpy. The characters comprising the strings do not need to be moved or changed in any way. Instead, the addresses pointed to by the string variables should be swapped.
#include
void swapIntegers(int *, int *);
int main(void) {
int num1 = 5, num2 = 10;
printf("Before the swap: num1 = %d and num2 = %d ", num1, num2);
swapIntegers(&num1, &num2);
printf("After the swap: num1 = %d and num2 = %d ", num1, num2);
return 0;
}
void swapIntegers(int *n1, int *n2) { /* passed and returned by using values of pointers */
int temp;
temp = *n1;
*n1 = *n2;
*n2 = temp;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
