Showing posts with label Program to count length of string. Show all posts
Showing posts with label Program to count length of string. Show all posts

Wednesday, July 20, 2011

Program to count length of string

/*Serial No.58     [swami31.cpp]*/

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[10],rev[10];
int i,length=0;
clrscr();
printf("Enter the string==>");
scanf("%s",str);
for(i=0;str[i]!='\0';i++)
{
length++;
}
 printf("\nThe Length of %s is==>%d",str,length);
 length--;
 for(i=0;length>=0;i++)
 {
 rev[i]=str[length];
 length--;
 }
 rev[i]='\0';
 printf("\nReverse of ---%s--- is ==> %s",str,rev);
 getch();
 }