#include <example.(h?)> - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Programming with C++ (https://www.supportforums.net/forumdisplay.php?fid=20) +---- Thread: #include <example.(h?)> (/showthread.php?tid=10052) |
#include <example.(h?)> - Reality - 07-18-2010 Why do some people do #include <stdio.h> for example, not just #include <stdio>? I don't understand -_- RE: #include <example.(h?)> - MrD. - 07-24-2010 Because you need to include the actual name of the file, but some of the standard library is available with or without the .h extension. Your own header files will likely always have a .h extension, so you will need to include them as MyHeaderFile.h and not just MyHeaderFile. RE: #include <example.(h?)> - mmki - 07-29-2010 its a good idea to always put the .h on the end. i think that goes with most like windows.h and iosteam.h I think it depends on the compiler is that correct? RE: #include <example.(h?)> - MrD. - 07-30-2010 The compiler won't care what the file is called as long as it can find it, you could call it MyHeader.holyshitlions if you wanted and providing you told the compiler what it was, it wouldn't care. The lack of a .h extension simply comes form the various versions of the C and C++ standards and backwards compatibility between them. RE: #include <example.(h?)> - Disease - 11-23-2010 (07-29-2010, 07:49 PM)mmki Wrote: its a good idea to always put the .h on the end. i think that goes with most like windows.h and iosteam.h When it comes to standard C headers, they always end with the .h extension. If you ever see them called without the extension then the programmer is writing non portable, malformed code. For standard C++ headers, however, there is no file extension. The files iostream.h and iostream are entirely different. Once upon a time the C++ headers had file extensions. But then C++ was standardized and the file extensions were dropped. Thus iostream.h is the old header and will contain now-obsolete code. |