Exno 5
Exno 5
Aim:
Procedure:
int main() {
char str1[20] = "C programming";
char str2[20];
// copying str1 to str2
strcpy(str2, str1);
printf("Value of second string is: %s",str2);
return 0;
}
Output:
Value of second string: C programming
5.2 Program to find the length of the string
#include <stdio.h>
#include <string.h>
int main()
{
char a[20]="Program";
char b[20]={'P','r','o','g','r','a','m','\0'};
printf("Length of string a = %d \n",strlen(a));
printf("Length of string b = %d \n",strlen(b));
return 0;
}
Output:
Length of string a:7
Length of string b:7
5.3 Program for compare the two strings
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main() {
char str1[20] = "hello";
char str2[20] = "world";
Result: