@chevon1920 You define the names and parameters of your function in the header file. Your actual implementation of how the method works would be in a .c file which includes this header file.
How to add functions in the main files from the header files. I mean you created the function definition but what about the body part of the function where do you define it......
I am making a calculator by using a dinamick stack and RPN, the prototypes of my functions are:
void push(Nodo **ptrPila,int valor);
void pop(Nodo **ptrPila);
I have all of that in a main file, but I'd like to use my pop and push functions as if they were part of c, like printf, and also could re- use those functions in more programs, but I'm only able to write the prototypes in a header file how can I add them their functionality then? like the one I wrote. THANKS.
@diegoramos27 My reply to this is the same as the other. You could make a separate .c file and then put all of your functions in that. Just reuse the c file and the header file.
Thank you a lot for this, I'm also a mac programmer and this has helped me a lot, it is really simple but couldn't find out how to do it, just a question, if I make a complex function in my header I need to include both the prototype and functionality in the same file right? Because I was told they would need to be separate, thanks in advance.
@diegoramos27 In general you would create the prototype in the header file and define it in your .c files. Usually the .h file only contains the prototype for the function.
But where do you actually define the function. Is it in the header file that you put in what should be in the function or the main.
chevon1920 4 days ago
@chevon1920 You define the names and parameters of your function in the header file. Your actual implementation of how the method works would be in a .c file which includes this header file.
AppleProgramming 4 days ago
@AppleProgramming
Ohhh, so the header file just has the declaration of the function and the .c file has a declaration and the actual function. ok Thanks so much!
chevon1920 4 days ago
Why do we need function prototypes anyway?
RMH1565 6 days ago
@RMH1565 If you look in the comments of the functions tutorial this will probably answer your question.
AppleProgramming 6 days ago
@AppleProgramming Thanks Buddy... Your series are awesome!!!
tuhinbhatt1 6 months ago
@AppleProgramming
How to add functions in the main files from the header files. I mean you created the function definition but what about the body part of the function where do you define it......
tuhinbhatt1 6 months ago
@tuhinbhatt1 You can define it either in a new C file or the same file (main.c) that the main method is in.
AppleProgramming 6 months ago
Comment removed
tuhinbhatt1 6 months ago
Comment removed
tuhinbhatt1 6 months ago
Love it!
kevinlau51 1 year ago
I am making a calculator by using a dinamick stack and RPN, the prototypes of my functions are:
void push(Nodo **ptrPila,int valor);
void pop(Nodo **ptrPila);
I have all of that in a main file, but I'd like to use my pop and push functions as if they were part of c, like printf, and also could re- use those functions in more programs, but I'm only able to write the prototypes in a header file how can I add them their functionality then? like the one I wrote. THANKS.
diegoramos27 1 year ago
@diegoramos27 My reply to this is the same as the other. You could make a separate .c file and then put all of your functions in that. Just reuse the c file and the header file.
AppleProgramming 1 year ago
Thank you a lot for this, I'm also a mac programmer and this has helped me a lot, it is really simple but couldn't find out how to do it, just a question, if I make a complex function in my header I need to include both the prototype and functionality in the same file right? Because I was told they would need to be separate, thanks in advance.
diegoramos27 1 year ago
@diegoramos27 In general you would create the prototype in the header file and define it in your .c files. Usually the .h file only contains the prototype for the function.
AppleProgramming 1 year ago