PDA

View Full Version : how to make the string function ?


clmlbx
19-02-2008, 01:48 PM
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
20-02-2008, 10:05 AM
#include<stdio.h>
#include<conio.h>
int strlent(char *a)
{
int i;
for(i=0;a[i]!='\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
20-02-2008, 12:55 PM
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)

clmlbx
25-02-2008, 09:43 PM
@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.........