How to invoke function from external .c file in C?

ProtoTyPus picture ProtoTyPus · Jan 21, 2014 · Viewed 154.7k times · Source

My files are

// main.c  

#include "add.c"

int main(void) {
    int result = add(5,6);
    printf("%d\n", result);
}  

and

// add.c  

int add(int a, int b) {
    return a + b;
}

Answer

Gaurav Jain picture Gaurav Jain · Jan 21, 2014

use #include "ClasseAusiliaria.c" [Dont use angle brackets (< >) ]

and I prefer save file with .h extension in the same Directory/folder.

#include "ClasseAusiliaria.h"