Added: 1 year ago
From: AppleProgramming
Views: 1,693
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (15)

Sign In or Sign Up now to post a comment!
  • 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 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

    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!

  • Why do we need function prototypes anyway?

  • @RMH1565 If you look in the comments of the functions tutorial this will probably answer your question.

  • @AppleProgramming Thanks Buddy... Your series are awesome!!!

  • @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 You can define it either in a new C file or the same file (main.c) that the main method is in.

  • Comment removed

  • Comment removed

  • Love 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.

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more