Possible Duplicate:
What is the difference between using #include<filename> and #include<filename.h> in c++
I've never noticed it making any difference whether or not I include the .h at the end of an include, so I've always ignored the meaning, but I've just noticed in a particular program of mine, I get the error "memcpy was not declared in this scope" if I include "string", but not if I include "string.h".
First of all, I was wondering the specific cause of this, but also generally the difference between the two. At the same time, if someone could explain the difference between includes in angular brackets and those in quotation marks, It'd be much appreciated.
If a header file happens to be included twice, the compiler will process its contents twice. This is very likely to cause an error, e.g. when the compiler sees the same structure definition twice. Even if it does not, it will certainly waste time. This construct is commonly known as a wrapper #ifndef.
In C program should necessarily contain the header file which stands for standard input and output used to take input with the help of scanf() and printf() function respectively.
The includes in the . c are only included when that one file is compiled, but the includes for the . h have to be included by every file that uses it.
Yes you can wirte a program without #include , but it will increase the complexity of the programmer means user have to write down all the functions manually he want to use.It takes a lot of time and careful attention while write long programs.
<string>
is the C++ standard library string header file containing std::string
and its friends. <string.h>
is a different header, from the C standard library, which has functions for manipulating C strings (null-terminated strings) and other related functions.
The two are entirely different and unrelated. In C++ (as in C), a header file can have any extension. The C++ standard library headers have no extension; the C standard library headers have a .h
extension. .hpp
or .hxx
are also common.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With