C Programming on the Mac L30 - Creating header files

preview_player
Показать описание
How to create your own header files
Рекомендации по теме
Комментарии
Автор

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

tuhinbhatt
Автор

@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
Автор

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.

diegoarmando-x
Автор

@tuhinbhatt1 You can define it either in a new C file or the same file (main.c) that the main method is in.

AppleProgramming
Автор

@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
Автор

@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

tuhinbhatt
Автор

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

AppleProgramming
Автор

fuck man, you saved my life, this tutorial did help

dcjunkieful
Автор

@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!

chevon
Автор

Sir, can you please tell what is the equivalent of graphics.h in xcode. How to use graphics.h in xcode.

binnyvirk
Автор

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.

chevon
Автор

@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
Автор

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.

diegoarmando-x
Автор

This confuses me... why wouldn't you define the function as the prototype in one group of code? I've tested it, it's obviously able to do this... It seems like it would save a LOT of time in the long run, and defining in the header seems to work well enough (and makes the main file more readable)... unless I'm missing a reason not to. Sorry, I've gone through thirty videos (to get to obj-C) in the last two days, and this is my only real complaint on your list. lol

feerspreads
Автор

Why edit C on xcode? Xcode is super heavy and doesn't do anything for C dev.

Wilson
visit shbcf.ru