Can I create a header file in Ideone?

1.3k Views Asked by At

Ideone's FAQ page doesn't cover that, I think. I am able to write my code in main.c or main.cpp respectively, but would I be able to create a header file, and include it to my main()?

For example, Overleaf for allows me to have multiple files.

3

There are 3 best solutions below

2
On BEST ANSWER

You don't strictly need to create a header to reproduce a piece of code that uses a header. You can perform the preprocessing manually, and copy the contents of the header in place of the include.

However, to demonstrate the behaviour of the preprocessor itself, the ability to create a header would be needed. I don't think that is possible on ideone.


https://wandbox.org/ appears to have proper support for multiple files.

On http://coliru.stacked-crooked.com it is technically possible by injecting from the command line. Not practical for long headers, for obvious reasons.

echo 'inline int foo(){return 42;}' > header.h && g++ main.cpp && ./a.out

demo

0
On

If you want to put something like

#include "xxx.h"

int main()
{
    xxx(int yyy));
    return 0;
}

Into ideone.com, just remove the #include bit, and cut'n'paste the file into location of the #include

i.e.

/* xxx.h header file */

void xxx(int);
#define YYY_DEFAULT 1

/* end of header file */
int main()
{
    xxx(int yyy));
    return 0;
}

This is exactly what the preprocessor effectively does.

0
On

Can I create a header file in Ideone?

No.

It seems that πάντα ῥεῖ is correct, about Ideone not providing this feature.

However, Wandbox does allow to include a header file, as well as source files (which could for example define the declared functions of the header files).

Example:

enter image description here