I have some files:
vetores.c // função main
uniao.c // função para unir vetores
ordena.c // função para ordenar vetores
globais.c // arquivo com variáveis globais
I want to know how I reference one file in the other.
Example: I need to use the variables of globais.c
in vetores.c
, as well as calling the functions of ordena.c
and uniao.c
in vetores.c
, and% in ordena.c
and others ... I tried using headers ( uniao.c
) files like this:
globals.h
#ifndef _GLOBAIS_H_
#define _GLOBAIS_H_
#include<stdio.h>
#include<stdlib.h>
int *A, *B, ta, tb;
#endif
Order.h
#ifndef _ORDENA_H_
#define _ORDENA_H_
int* ordena(int *vet, int tam);
#endif
uniao.h
#ifndef _UNIAO_H_
#define _UNIAO_H_
int* uniao( int *vet1, int tam1, int *vet2, int tam2);
#endif
And in the files .h
I used references like this:
#include"uniao.h"
#include"globais.h"
#include"ordena.h"
I also tried straight through .c
:
#include"uniao.c"
#include"globais.c"
#include"ordena.c"