Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

The compiler is saying "no such file" about a header file I am including in main

+8 votes
asked Jul 25, 2023 by David Siff (200 points)
edited Jul 26, 2023 by David Siff

In my C++ project I included a file "Btree.h"

In main i wrote:

#include "Btree.h"

I am getting a compilation error: "no such file or directory"

the project is at https://onlinegdb.com/tI-Qdyuye

3 Answers

0 votes
answered Jul 26, 2023 by Peter Minarik (86,240 points)
It looks like you've already solved the issue if Iook at the linked project.

Just a note: I've never seen anyone use a space in an include file name before. It's good to know it works. :)

However, this could make your life harder in some situations, so I'd recommend not putting spaces into file names. Use e.g. "IntQueue.h" instead.
commented Jul 26, 2023 by David Siff (200 points)
sorry--wrong link--no, I have not resolved it
commented Jul 26, 2023 by Peter Minarik (86,240 points)
You will learn that the compiler is correct 99.999% of the time. :)

It's right again: you cannot include "Btree.h" because you have no such file. Your file is called "BTree.h" (capital 'T' instead of lower case 't').
If you click on the ellipsis (three dots) next to the file name, you can rename the file to have the correct name: "Btree.h".

Note, after this you will have more compilation issues, but the include line now works. :)
commented Jul 26, 2023 by Peter Minarik (86,240 points)
The next compilation issue is due to the INT_MIN not being defined in the C++ <limits> header, but the C header file <climits> (or <limits.h>)

In the destructor of Stack, you must not specify the size when you delete the allocated memory:

delete[] bottom;

After this, your code would compile. I'll leave you to have fun with any further issues you find (e.g. #pragma once is twice in Stack.h and doing the conversion of your containers to generic containers / templates)

Have fun! :)
0 votes
answered Jul 27, 2023 by lizhen9880 (140 points)

your C file:  #include "Btree.h", but your h filename is BTree.h.( Match case? )

0 votes
answered Aug 14, 2023 by Mehnazali (140 points)
#include <Btree.h>
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...