Answer the question
In order to leave comments, you need to log in
Why do I need to declare a function that I will use later in the code?
Why do you need to write char **AddPtr (char **pp, int size, char *str);
before the entry point?
#include <iostream>;
#include <string.h>;
using namespace std;
char **AddPtr (char **pp, int size, char *str); //прототип функции
int main()
{...}
Answer the question
In order to leave comments, you need to log in
Because the compiler (more precisely, its piece - like a parser) looks at the code sequentially. And if he finds the use of the function before its declaration, then he will not be able to understand whether you are using it correctly or not. Of course, you can make several passes - first collect all the functions, and then check the correctness - but this will increase the check time. Therefore, you must first declare a prototype - make it clear to the compiler that such a function will be and with what parameters, and then use it.
Specifically, the location relative to main has nothing to do with it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question