Tom
Tom

Reputation: 69

How to include a C library for multiple files

I have a program that went like this:

//this is main.c
#include <stdio.h>
#include <stdlib.h>
...
#include "fileA.c"
#include "fileB.c"
...

//rest of main file

which worked fine but now when I replicated the exact same project (in VS) all the other files in the project don't seem to recognize the standard library #includes from some reason.

any help please?

Upvotes: 2

Views: 233

Answers (1)

machine_1
machine_1

Reputation: 4454

Other files are independent files. As such, you must include the relevant header files in those files as well. Also, it is not considered a good practice to include .c files as it can easily result in linking errors due to multiple definitions.

Upvotes: 4

Related Questions