I would like to know what is the most recommended use of *.h
files? Well I do not know if I can use them just to put the prototype functions or the function completely.
I would like to know what is the most recommended use of *.h
files? Well I do not know if I can use them just to put the prototype functions or the function completely.
Most .h files are only meant to refer to a method that is in a .c, .a, .so, .o, or .dll file, but that does not prevent you from putting the features inside them, just is not semantically correct. an example to use is like this ...
file.h
#ifndef FILE_H
#define FILE_H
#include <stdio.h>
#include <malloc.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
void method_01(void);
int method_02(int , int);
const char * method_return_string();
#endif /*FILE_H*/
file.c
#include "file.h"
void method_01(void){
puts("method called...");
}
int method_02(int x, int y){
return x+y;
}
const char method_return_string(){
char *c = (char*) malloc(sizeof(char)*60);
strcat(c,"my text");
return c;
}