In: Computer Science
Assume we have two string variables:
Shakespeare byte 'Brevity is the soul of wit' and
Poet byte 'The problem is not in the stars but within ourselves'
Write a AL program that will interchange the contents of the two variables.
1. group of character is nothing but String .we can create string object . once we create string object and we cant change string value.But we can intercahnge the string values.
for example.
#include#include #include int main() { char first[100], second[100], *temp; printf("Enter the first string\n"); gets(first); printf("Enter the second string\n"); gets(second); printf("\nBefore Swapping\n"); printf("First string: %s\n",first); printf("Second string: %s\n\n",second); temp = (char*)malloc(100); strcpy(temp,first); strcpy(first,second); strcpy(second,temp); printf("After Swapping\n"); printf("First string: %s\n",first); printf("Second string: %s\n",second); return 0; }