Perform string manipulation using string functions
Program:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str1[40], str2[40];
clrscr();
printf("Enter the first string : \n\n");
gets(str1);
printf("\nEnter the second string : \n\n");
gets(str2);
printf("\nString 1 = %s & String 2 = %s ", str1, str2);
printf("- Length is : %d and %d", strlen(str1), strlen(str2));
printf("\n\nString 1 = %s & String 2 = %s ", str1, str2);
printf("- Uppercase is : %s and %s", strupr(str1), strupr(str2));
printf("\n\nString 1 = %s & String 2 = %s ", str1, str2);
printf("- Lowercase is : %s and %s", strlwr(str1), strlwr(str2));
printf("\n\nString 1 = %s & String 2 = %s ", str1, str2);
printf("- Reverse is : %s and %s", strrev(str1), strrev(str2));
printf("\n\nString 1 = %s & String 2 = %s ", str1, str2);
printf("- String copy is : %s ", strcpy(str1,str2));
printf("\n\nString 1 = %s & String 2 = %s ", str1, str2);
printf("- Concatenation is : %s ", strcat(str1,str2));
printf("\n\nString 1 = %s & String 2 = %s ", str1, str2);
getch();
}
Output:
Enter the first string :
Anna
Enter the second string :
Madras
String 1 = Anna & String 2 = Madras - Length is : 4 and 6
String 1 = Anna & String 2 = Madras - Uppercase is : ANNA and MADRAS
String 1 = ANNA & String 2 = MADRAS - Lowercase is : anna and madras
String 1 = anna & String 2 = madras - Reverse is : anna and sardam
String 1 = anna & String 2 = sardam - String copy is : sardam
String 1= sardam & String 2= sardam - Concatenation is : sardamsardam
String 1 = sardamsardam & String 2 = sardam
-
UpdatedDec 31, 2019
-
Views4,507
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order