how to make the string function ?

Status
Not open for further replies.

clmlbx

Technomancer
hello ,

I KNOW what is string.h and all it's function........(strrev,strcpy,strlen.and all )but how to make their own defined functions...how to pass the value to programme ..................[THAT SELF MADE FUNCTION.........THAT WE DEFINE BEFORE MAIN() FUNCTION.]
 

manubatham20

Broken In
#include<stdio.h>
#include<conio.h>
int strlent(char *a)
{
int i;
for(i=0;a!='\0';i++);
return i;
}
void main()
{
char a[100];
clrscr();
printf("\n\n\t\tEnter the string = ");
fflush(stdin);
gets(a);
printf("\n\n\t\t The length of the string is = %d",strlent(a));
getch();
}

The above is the function for computing string length. Try next two by yourself. Keep asking...
 

legolas

Padawan
alternatively and more advantageously, you can also construct your own custom header file with definitions and declarations in a C file and include that header file. (not for already built in functions like these, but other functions like say, computing integration or differential equations solution or bessel functions or as in ur case, custom string operations that doesn't exist in the package)
 
OP
clmlbx

clmlbx

Technomancer
@manubatham20

thanx for it, really sorry for late reply but was very busy............in that (strlent function) numeric value was returned from function how to pass a string from function.....means make a function to get reverse string (strrev)......

can anyone help me ?

I have a problem in that only how to return a value ,means in that u return value of I and printout 'a'................so how it happened.........
 
Status
Not open for further replies.
Top Bottom