write a c program for swapping two strings using pointer
Answer / Hitesh Kumar Gupta
Here's an example C code for your request:
```
#include <stdio.h>
void swapStrings(char *str1, char *str2) {
char temp[100];
strcpy(temp, str1);
strcpy(str1, str2);
strcpy(str2, temp);
}
int main() {
char str1[100] = "Hello";
char str2[100] = "World";
printf("Before swap: %s and %sn", str1, str2);
swapStrings(str1, str2);
printf("After swap: %s and %sn", str1, str2);
return 0;
}
```
| Is This Answer Correct ? | 0 Yes | 0 No |
a linear linked list such that the link field of its last node points to the first node instead of containing NULL a) linked list b) circular linked list c) sequential linked list d) none
Function calling procedures? and their differences? Why should one go for Call by Reference?
Diff between for loop and while loop?
What is the Difference between Macro and ordinary definition?
3 Answers Bosch, Cognizant, College School Exams Tests, Motorola,
main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none
when i declare as: void main() { clrscr(); int a=10; printf("%d",a) } my problem that why generate a error in above programs. please tell me answer seriously .
How do you determine whether to use a stream function or a low-level function?
If the static variable is declared as global, will it be same as extern?
What is the correct declaration of main?
question-how to run a c programme.
write a program whose output will be- 1 12 123 1234
What is the use of getchar() function?