/* C program to find the length of the given string with out using built in functions */
main()
{
char a[30];
int l;
puts("enter any string");
gets(a);
for(l=0;a[l]!='\0';l++);
printf("\n length of given string %s is is %d",a,l);
}
OUTPUT:
enter any string ashok
length of given string ashok is 5
/* C program to copy one string to another string with out using built in functions */
main()
{
char a[30],b[30],l,i;main()
{
char a[30],b[30],l,i;
printf("\n enter any string");
gets(a);
for(l=0;a[l]!='\0';l++); / * length of the string */
for(i=0;i<l;i++)
{
b[i]=a[i]; /* copying characters from a to b */
}
printf("\n copied string is");
puts(b);
}
OUTPUT
enter any string
anil
copied string is anil
/* C program to compare two string with out using built in functions */
main()
{
char [30],b[30];
int l1,l2,i=0;
printf("enter the first string");
gets(a);
printf("enter the second string");
gets(b);
for(l1=0;a[l1]!='\0';l1++); /* length of the first string */
for(l2=0;a[l2]!='\0';l2++); /* length of the second string */
if(l1!=l2)
{
printf("both strings are not equal");
exit(1); /* program ends */
}
for(i=0;a[i]!='\0';i++)
{
if(a[i]!=b[i])
{
c=1;
break;
}
}
if(c==0)
printf("\n both strings are equal");
else
printg("\n both string are not equal");
OUTPUT:
enter the first string
ashok
enter the second string
ashoi
both string are not equal
string handling in C, string programs without using built in functions, palindrome program with out using built function c . string length, string reverse
No comments:
Post a Comment