0

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.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
gsamaras
  • 71,951
  • 46
  • 188
  • 305
  • 2
    Why do you need to do this on ideone? It is just for trying stuff out - just cut'n'paste the header - as the preprocessor would do. – Ed Heal May 24 '17 at 12:32
  • 4
    AFAIK you can't. But there's [wandbox](http://melpon.org/wandbox). – πάντα ῥεῖ May 24 '17 at 12:33
  • EdHeal well I was trying to answer this question..So yes just to try out. @πάνταῥεῖ cool, didn't know that. I posted an answer based on your comment, but if you feel like posting one, let me know and I will delete it at once. – gsamaras May 24 '17 at 12:51
  • We are not the support forum of ideone. Why don't you are on their site? – too honest for this site May 24 '17 at 13:08
  • @πάνταῥεῖ Wandbox is so good, danke for your suggestion! :) TooHonestForThisSite, I will keep your tip for next time, thanks! – gsamaras Nov 23 '18 at 08:56

3 Answers3

1

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.

Ed Heal
  • 59,252
  • 17
  • 87
  • 127
1

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

gsamaras
  • 71,951
  • 46
  • 188
  • 305
0

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

eerorika
  • 232,697
  • 12
  • 197
  • 326