Possible flaws in ‘including *.c files’ style C programming


I came across some codes in the following way

#include <stdlib.h>

void print(void){

    printf("Hello world\n");


//file main.c  
#include <stdio.h>
#include "file.c"

int main(int argc, char *argv[]){


    return EXIT_SUCCESS;

Is there any flaw in this kind of programming style? I am not able to make out the flaw although I feel so, because somewhere I read that separating the implementation into *.h and *.c file helps compiler check for consistency. I don't understand what is meant by consistency.
I would be deeply thankful for some suggestions.


Best Solution

It is not uncommon to include data in another file if it is more convenient to separate it from the code. For example, XPM or raw BMP data in a char array could be included to embed an image in the program in this way. If the data is generated from another build step then it makes sense to include the file.

I would suggest using a different file extension to avoid confusion (e.g. *.inc, *.dat, etc.).

Related Question