C Programming - C Preprocessor - Discussion

Discussion Forum : C Preprocessor - Yes / No Questions (Q.No. 4)
4.
It is necessary that a header files should have a .h extension?
Yes
No
Answer: Option
Explanation:

No, the header files have any kind of extension.

Discussion:
16 comments Page 1 of 2.

Himani said:   1 decade ago
Then why do all the predefined header files have ".h" as there extension.
(1)

Avkash Agrawal said:   1 decade ago
We know that we use many headder file such as

stdio.h, dos.h, conio.h, stdlib.h, graphics.h, iostream.h etc.

So how can you say that there is no need of this extension ?

Atul said:   1 decade ago
Can you tell me what are all the other extensions other than .h ?

Manishsoni said:   1 decade ago
How can this possible please anyone elaborate it ?

Mani kandan said:   1 decade ago
We can define fact.c, filename.c in header file.

So, if you mention filename.c, it will read the entire file.

Sundar said:   1 decade ago
@ALL

Is is necessary that a header files should have ".h" ?

Answer is NO.

Because the header files can have any extension but it should be included with in C program with same extension.

Let me explain what I did to check this...

In Turbo C directory

C:\Turbo>copy stdio.h stdio.hdr
C:\Turbo>copy conio.h conio.exe

Then I used the line following line to include the header file.

#include<stdio.hdr>
#include<conio.exe>

void main()
{
printf("Welcome to IndiaBIX.com !");
getch();
}


The output : Welcome to IndiaBIX.com !

Kapil said:   1 decade ago
No such header files exist without .h extension.

Moni said:   1 decade ago
In c++ it accept without .h extension but in c its possible ?

Lalit kumawat said:   1 decade ago
Without .h extension it is not possible to include the function like printf, scanf etc.

Jyoti Nagpal said:   1 decade ago
#include"filename.c".

"this is also a header file".

In a extern concept, many different files can use same variable.

By using include the whole file.

That's all about it.

Thanks.


Post your comments here:

Your comments will be displayed after verification.