Question

I kinda like codepad online editor (supports C++), but I'd like to use some scanfs which is not possible with codepad.

Is there some online C++ compiler that supports input streams? Is that even possible?

Was it helpful?

Solution

IDEOne supports passing in the input; you can specify it in a <textarea>.

OTHER TIPS

[ Disclaimer: I prefer ideone.com (has c++0x support as well) ]

Getting very pedantic, you could stuff your input inside the source file by playing this dirty trick:

http://codepad.org/fjtHRgof

/* just skip the first two (!!!) lines when reading from t.cpp
602.030024387
423.927317911
520.43881927
131.655014874
35.7455352247
548.735653436
714.556123804
876.948673754
379.105540406
885.096900058
192.734103705
116.365922766
363.998415895
216.268387112
958.684513705

*/ // end of fake input

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    std::ifstream ifs("t.cpp");
    std::cout << ifs.rdbuf() << std::flush;
}

Rextester has an input box as well and has a more usable interface than ideone which I have always felt was very clunky.

Coliru allows you to use multiple files, so you can create an file with your data and do something like this to input into your program:

g++ -std=c++11 -W -Wall main.cpp && cat /Archive/{{id}}/main.cpp | a.out

Note, LWS also has a nice interface and an input box but has been in read-only mode for a while now and it is not clear it is coming back online anytime soon if at all.

You can try http://optimizedbits.com . There you can also compile your code by providing your own stream of multiple inputs.

For just one input stream, simply write the input. For multiple input test cases, follow:

input1
<TESTCASE>
input2
<TESTCASE>
....

Regarding the possibility of input stream: See no body builds a compiler on their own. Everybody utilizes some standards like gcc in the back-end. All online compiler websites work around a architecture which involves the following flow(example:C++):

1) read_code_user
2) Save it as variablename.cpp
3) Use a queuing framework. Then execute g++ variablename.cpp. Further, various libraries are utilized which can pipe stdin, stdout and stderr. 

try http://compileonline.com/ enter your input in STDIN

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top