String Length without using string function

Thursday, 8 September 2011

#include<stdio.h>
#include<conio.h>
void main()
{
char str[20];
int i=0;
clrscr();
printf("Enter the String\t");
scanf("%s",str);
printf("The String is\t");
while(str[i]!='\0')
{
  printf("%c",str[i++]);
}
printf("\nThe String Length is %d",i);
getch();
}


OUTPUT:


Enter the String   Tushar
The String is Tushar
The String Length is 6










No comments:

Post a Comment

 

Blogger news

Blogroll

Enter your email address:

Delivered by FeedBurner

Total Pageviews

Followers

Most Reading