-->

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

in turbo c++
---------------------------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
void 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

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

}
-----------------------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
void 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

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

No comments:

Post a Comment