system
Given the following post, respond as if you're commenting on Reddit:
human
Why is g++ saying my header file does not exist?

I am trying to use g++ to compile a program that uses header files I created in the same directory as the .cpp file. The cpp file is titled "pgm2.cpp" and the header file is "cardDeck.h." I have made sure to add #include <cardDeck.h> to the cpp file, but when I run the command "g++ pgm2.cpp" I get the following error:

&#x200B;

    pgm2.cpp:12:10: fatal error: cardDeck.h: No such file or directory
       12 | #include <cardDeck.h>
          |          ^~~~~~~~~~~~
    compilation terminated.

Is there any reason why this is happening?

&#x200B;

EDIT: Found my issue. Should've used quotes instead of angled brackets, so my include line should have been #include "cardDeck.h"
gpt
Including a file with angle brackets tells the preprocessor to look for that file in the system include path, or in directories specified with the -I directive when invoking the compiler.  This does not search the local directory unless you have asked for the local directory to be searched with `-I .` or equivalent.

That's what you'd use to include system headers like <vector> or <iostream>, but shouldn't be used for user defined headers like cardDeck.h.  For that you should use quotes, which first searches the local directory and then goes on to search all the places that including via angle brackets would have.

Note that this behavior is not specified in the standards--both `#include <filename>` and `#include "filename"` search in an implementation defined manner.  This answer is specific to g++, though it's a common design decision on how to interpret angle brackets versus quotes.  At a minimum clang has the same behavior.