can a file other than a .h file be included with #include

can a file other than a .h file be included with #include

Answer : Yes :)
Any file can be included using #include.. #include just inserts the contents of that file in your C program.

Answer : Yes :)
Any file can be included using #include.. #include just inserts the contents of that file in your C program.

can you give me any program as example, in which we are using #include and a file other than .h extension

can you give me any program as example, in which we are using #include and a file other than .h extension

Lets sayI have a file main.c and helloworld.inc
In main.c I will write

#include "helloworld.inc" //Including a file other than .h

and in
helloworld.inc I will write

#include <stdio.h>

int main()
{
        printf("Hello, World\n");
        return 0;
}

Now compile main.c and run the executable, It will print

Hello, World

yes the program i am working on now starts with:

#include <stdio.h> 
#include <string.h>
#include <stdlib.h>
#include <winsock2.h>
#include "myramdomize_windows2010.c"
#include "CRC_simple_windows.c"

#define WSVERS MAKEWORD(2,0)
WSADATA wsadata;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.