-->

wap to get length of string by passing string as parameter.

in turboc++
-----------------------------------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
#include<string.h>
int stringlength(char array[40]);//prototype with array string; we can also use simply array[]
int main()
{
char arr[20];            // array declaration with maximum limit 20
                     
printf("enter string\n");
gets(arr);//gets string

printf("the length=%d",stringlength(arr));//calling of function with argument
getch();
return 0;
}
int stringlength(char array[40])//body line
{
return strlen(array);
getch();
}

---------------------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
#include<string.h>
int stringlength(char array[40]);//prototype with array string; we can also use simply array[]
int main()
{
char arr[20];            // array declaration with maximum limit 20
                       
printf("enter string\n");
gets(arr);//gets string

printf("the length=%d",stringlength(arr));//calling of function with argument
return 0;
}
int stringlength(char array[40])//body line
{
return strlen(array);
getch();
}

No comments:

Post a Comment