C++ #include <[filename]> but #include <string> is not a filename

289 views Asked by At

DUPLICATE:
When can you omit the file extension in an #include directive?


I feel a little cleverer after finding:
What is the difference between #include <filename> and #include "filename"?

But in my code I use #include <string>.
string is not a valid filename and the angle brackets are not put in "".

Is this a third way of including other files or how do I have to understand this?
In other words, what is <string>?

2

There are 2 answers

4
The Paramagnetic Croissant On BEST ANSWER

string is not a valid filename

It is. The name of the header file is literally string. Search your include paths, e. g.:

find /usr/include /usr/local/include -name "string"

and you will have some results.

0
Sagar Kar On

What are file extensions?

They are some OS (popularly windows ) own way to identify file type to use its default app to open it. Whereas Mac and Linux use MIME for identification of file type.

“MIME” stands for Multipurpose Internet Mail Extensions

So in this case of library its the same. It is made using MIME type and since our windows os dont need to open that file other than a using specific IDE we are saved form a problem of file identification.