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.

Why are my header guards not working properly?

0 votes
asked Dec 17, 2018 by WILLIAM CAREY (300 points)
edited Dec 18, 2018 by WILLIAM CAREY

I'm trying to make a program in which I include the library "conio.h", but I need to include it in two separate files. Whenever I try to run it, I get a multiple definition error. 
The source for conio.h can be found here.
I've been having to include almost all of my functions in main.cpp and it's getting quite inconvenient to have to scroll past it to get to my main function.
I've tried everything I can think of, including having extra #ifndef's and #define's in my cpp files. That looked something like this:
#ifndef EXAMPLE_H
#define EXAMPLE_H
#include "conio.h"
#endif

2 Answers

0 votes
answered Dec 18, 2018 by Samin Riasat (140 points)

Maybe try <conio.h> instead of "conio.h". Also, try including it in one file only.

0 votes
answered Apr 12 by Finlay Mitchell (240 points)
Because conio.h is a standard library so use #include <conio.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.
...