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

C PROGRAM help

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!