Social Icons

banner image

string programs in c in built functions

operations on string

sstr operations

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,b;
char str1[80],str2[80];
printf("Enter a string");
gets(str1);
printf("Enter another string");
gets(str2);
if(strstr(str1,str2)==NULL)
printf("Not Found");
else
printf("found");
getch();
}
conversion lower to upper
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[20];
int len;
printf("Enter first string\n");
gets(str);
len=strlen(str);
printf("Length of string is %d\n",len);
printf("Upper case transformation is : \n");
puts(strupr(str));
printf("Lower case transformation is : \n");
puts(strlwr(str));
printf("Reverse is : \n");
puts(strrev(str));
getch();
}
string copy
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char ori[20],dup[20];
int i ;
printf("Enter string");
gets(ori);
strcpy(dup,ori);
puts("Original string is ");
puts(ori);
puts("Duplicate string is ");
puts(dup);
getch();
}
  string comparison
#include<stdio.h>
#include<conio.h>
void main()
{
int i,b;
char str1[80],str2[80];
printf("Enter a string");
gets(str1);
printf("Enter another string");
gets(str2);
if(strcmp(str1,str2)==0)
   printf("Strings are equal");
else
   printf("Strings are not equal");

getch();
}
string programs in c in built functions string programs in c in built functions Reviewed by Shobhit Goel on August 30, 2015 Rating: 5

1 comment:

Airtel Hackaton 2017

Powered by Blogger.