String Functions in C program

// using strlen length of word eg:wildcat ans: 7

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char msg[20];
int len;
printf("Input message:");
scanf("%s",msg);
{

len=strlen(msg);
printf("Length of the message=%d",len);
}
}

// using strrev eg: WILDCAT Ans: TACDLIW

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char msg[20];

printf("Input message:");
scanf("%s",msg);
{

strrev(msg);
printf("reversed message=%s",msg);
}
}

// using strupr UPPERCASE

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char msg[20];

printf("Input message:");
scanf("%s",msg);
{

strupr(msg);
printf("uppercase message=%s",msg);
}
}

// using strcpy

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char msg1[20];
char msg2[20];
printf("Input message:");
scanf("%s",msg1);
{

strcpy(msg2,msg1);
printf("message copied from %s to %s",msg1,msg2);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Enter Captcha Here : *

Reload Image