Ask coding questions

← Back to all posts
I am having problems including something
NicholasHartma1 (1)

I am having trouble including a header file from my project. In main .cpp i have the #include “filename.h” yet the compiler is out putting and error saying expecting “FILENAME” or <FILENAME> the file name is spelled correctly and is in the same folder as the including main.cpp. Is there something I am doing wrong?

Answered by heyitsmarcus (287) [earned 5 cycles]
View Answer
heyitsmarcus (287)

TL;DR: you just need to delete the quotation marks around student.h and retype so that it can get the correct double quotes. Although I do recommend looking at what I said below.

I took a look at your repl, and found out what the issue was. If you look at the output from the console, you'll notice that it says #include ”student.h” as part of the error. It's especially noticeable in the actual console output because it renders those double quotes as their fancy counterpart. What you pasted into the console are not standard quotation marks, they are both Right Double Quotation Marks, which the C++ compiler does not recognize as a valid quotation mark.

Often times, this error happens when you copy and paste from a Word document or some other rich text editor where quotation marks get written to the document as their fancier counterparts. If you copy and paste first into a program such as Notepad on Windows or TextEditor on Mac, you can notice that the double quotes are different than standard double quotes.

I tested and made sure that Hello World! outputs to the screen after doing this.

If this helped you solve your problem, please consider upvoting and marking my answer as the accepted answer to close this question.

NicholasHartma1 (1)

@heyitsmarcus Thanks for that. I am writing the code on a iPad and I didn't even realize that it was using different quotation marks. I would have been banging my head against that for awhile. Thank you very much I have the problem solved.

heyitsmarcus (287)

@NicholasHartma1 I just did a search for a good editor on the iPad (I don't have one), but Coda sounds like a pretty good app that is free for coding on there. There are some other paid ones that you can use, but I couldn't possibly recommend any since I haven't tried any of them.

And you are very welcome! I'm happy to help.