Friday, 17 February 2012

How to find Length of string in c using pre-define function

/*using predefine function*/
#include<stdio.h>
#include<stdlib.h>


void main()
{
     char string[100];  //varible string type
     int len;                  //varible integer type to store value of string length


     strcpy(string,"I am best");  //predefine function use to copy string to varible
     len=strlen(string);                //length of string store in variable
     printf("my string is %d",len);   //print length of string


}

No comments:

Post a Comment

Compiler for C,C++ and Python {paste your programme to see the output}