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.

How do I include a user defined header file in my project created in OnlineGDB?

–4 votes
asked May 5, 2020 by Eric VanSchaick (240 points)
Ex. main.cpp, sample.h I created both and want to include sample.h in main.cpp

I tried putting it in " " - #include  "sample.h" and they are both in the same project but main.cpp couldn't find sample.h

1 Answer

0 votes
answered May 16, 2020 by Dontwait00 (180 points)

Very simple. I will write for you a simple example.

main.c

#include <stdio.h>

#include "simple.h"

int main (void)  {

          printToken("hello everyone, i hope this help you");

          return (0);

}

simple.h

#pragma ONCE

// the header usually contains only prototypes or global variables

void printToken(char *string);

simple.c

#include <stdio.h>

#include "simple.h"

// this file contains the functions which "simple.h" reads from.

void printToken(char *string)  {

          printf("%s", string);

          return;

}

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.
...