answersLogoWhite

0


Best Answer

int mystrlen (const char *s)

{

const char *t;

if (!s) return 0;

for (t=s-1;*++t;);

return t-s;

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a function called mystrlen that receives a pointer to a character string so that the function return the length of the string?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

A pointer to function which receives an int pointer and returns a float pointer?

float *(*funptr)(int *); float *fun (int *); funptr= fun;


Function pointer that will point to a function that takes integer value and return character?

Answerchar (*funcp(int));


What is the difference between value type parameters and reference type parameters?

When a variable is passed by value, the function receives a copy of the variable. When a variable is passed by reference, the function receives a reference, or pointer, to the original data.


How can you declare a pointer function?

*function();this declares a pointer function!


What is the difference bw function pointer and function of pointer?

function pointer is a variable that hold the address of any function which declared in the program but function pointer is the array of the function that accept the run time size of the function.


What is the difference between a function pointer and a pointer to a function?

A pointer to a function is the memory address that stores the address of a function, while the pointer itself is a function pointer.A pointer to a function might be defined as "int (*pf)(int, int);", while to actually point to the function, you would use a function pointer, such as "pf = &func;".


A pointer to a function which receives nothing and returns nothing?

void (*funptr)(void); void fun (void); int main () { funptr = fun; funptr (); }


What is the syntax to return a Pointer To A Character?

A function f() will can be defined as returning a pointer to a character with the syntax char *f() { } One must be careful in creating these functions that the character pointer is set to point to a static variable or an allocated string; an automatic variable will vanish when the function exits, leaving the pointer invalid. I should point out that this is very basic C syntax. If this question is being asked as part of a school assignment, I must suggest that perhaps you should drop this course now, as it will be immeasurably harder as you get further into it.


Which two pointer does not increment or decrement in arithmetic array?

constant pointer and character pointer


What is pointer to pointer with examle?

int main (int argc, char **argv):Hereargv is a pointer to a pointer (points to the first element of a pointer-array)argv[0] is a pointer (points to the first character of a string)argv[0][0] is a character


C program pointers to pointers examples?

Pointer to Pointer is a double pointer, denoted by (**). Pointer stores the address of the variable and pointer to pointer stores the address of a pointer variable and syntax can be given as int **ptr2ptr;


Pointer to pointer in c?

Usable. A prominent example is param argv of function main.