Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
111 views
in Technique[技术] by (71.8m points)

c - Functions been used as pointers

I'm doing an exercise for my college and I am somewhat lost on pointers.

The whole exercise is telling us to make a function char *mystrcpy(char *dest, char *src). So what we need is to make an already included in <string.h> by ourselves.

It's not that hard as for the logical steps of the function, but i don't get why we need to use the function char *mystrcpy() as a pointer. Also how do we use functions as pointers and why?

question from:https://stackoverflow.com/questions/65924454/functions-been-used-as-pointers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You don't need a pointer to function but a function that return a pointer. like :

   char* strcpy(char* destination, const char* source);

that return a pointer to destination.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...