Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- char a[100],b[100],temp[100];
- int i,la,lb;
- printf("Enter the first string: ");
- fgets(a,sizeof(a),stdin);
- printf("Enter the second string: ");
- fgets(b,sizeof(b),stdin);
- for(la=0;a[la]!='\0';la++);
- for(lb=0;b[lb]!='\0';lb++);
- for(i=0; i<lb; i++)
- temp[i] = b[i];
- for(i=0; i<la; i++)
- b[i] = a[i];
- for(i=0; i<lb; i++)
- a[i] = temp[i];
- a[lb-1]='\0';
- b[la-1]='\0';
- printf("String A is %s and String B is %s.",a,b);
- }
- //Output
- //Enter the first string: Hello
- //Enter the second string: Hi
- //String A is Hi and String B is Hello.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement