using codeblocks
----------------------------------------------------------------------------------------------------------
//program to find length of string using pointer passed to function// program title
#include <stdio.h> //header file
#include <string.h> // header file to handle string
void string_length(char []); // function prototype with character array.compiler supports this. You //can also write char string[50].
int main()
{
char string[50]; // character string
puts("enter string\n");
gets(string); //gets string
string_length(string); //calling of function with string as parameter
// here, string is passed as reference to formal parameter
return 0;
}
void string_length(char *strings)// this accepts string with address
{
int length;
length=strlen(strings); // supplies length
printf("total length=%d\n",length);//displays length
}
//note: we can also use char string[] with void string_length in body line. It works.
//once you try.It runs.
//but we can not pass string as pointer in prototype.
// i.e. void string_length(char *[]);
------------------------------------------------------------------------------------------------------
using turbo c++
-----------------------------------------------------------------------------------------------------
//program to find length of string using pointer passed to function// program title
#include <stdio.h> //header file
#include <string.h> // header file to handle string
#include<conio.h>
void string_length(char []); // function prototype with character array.compiler supports this. You //can also write char string[50].
int main()
{
char string[50]; // character string
puts("enter string\n");
gets(string); //gets string
string_length(string); //calling of function with string as parameter
// here, string is passed as reference to formal parameter
getch();
return 0;
}
void string_length(char *strings)// this accepts string with address
{
int length;
length=strlen(strings); // supplies length
printf("total length=%d\n",length);//displays length
}
//note: we can also use char string[] with void string_length in body line. It works.
//once you try.It runs.
//but we can not pass string as pointer in prototype.
// i.e. void string_length(char *[]);
----------------------------------------------------------------------------------------------------------
//program to find length of string using pointer passed to function// program title
#include <stdio.h> //header file
#include <string.h> // header file to handle string
void string_length(char []); // function prototype with character array.compiler supports this. You //can also write char string[50].
int main()
{
char string[50]; // character string
puts("enter string\n");
gets(string); //gets string
string_length(string); //calling of function with string as parameter
// here, string is passed as reference to formal parameter
return 0;
}
void string_length(char *strings)// this accepts string with address
{
int length;
length=strlen(strings); // supplies length
printf("total length=%d\n",length);//displays length
}
//note: we can also use char string[] with void string_length in body line. It works.
//once you try.It runs.
//but we can not pass string as pointer in prototype.
// i.e. void string_length(char *[]);
------------------------------------------------------------------------------------------------------
using turbo c++
-----------------------------------------------------------------------------------------------------
//program to find length of string using pointer passed to function// program title
#include <stdio.h> //header file
#include <string.h> // header file to handle string
#include<conio.h>
void string_length(char []); // function prototype with character array.compiler supports this. You //can also write char string[50].
{
char string[50]; // character string
puts("enter string\n");
gets(string); //gets string
string_length(string); //calling of function with string as parameter
// here, string is passed as reference to formal parameter
getch();
return 0;
}
void string_length(char *strings)// this accepts string with address
{
int length;
length=strlen(strings); // supplies length
printf("total length=%d\n",length);//displays length
}
//note: we can also use char string[] with void string_length in body line. It works.
//once you try.It runs.
//but we can not pass string as pointer in prototype.
// i.e. void string_length(char *[]);