Click here to Skip to main content
15,889,826 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm making a website where user can write c++ code that will be compiled on my server. I'm using php exec function for compiling the code, but it doesn't allow user to interact with the code, i.e. take user input.

What I have tried:

I tried opening command prompt as a background process and then running the cpp executable file, still i cant take user input or use cin.
I need help taking user input.
I'm making something like codecademy but for C++ interactive tutorial.
Posted
Updated 21-Dec-16 6:30am
Comments
Richard MacCutchan 21-Dec-16 12:07pm    
No it won't, because the execed process runs on the server, and the server input is expected to come from directly connected devices, not from remote stations.
Tashifa 21-Dec-16 12:29pm    
can you guide me how online compilers let users interact with C++ program where user input is required through 'cin'?
Richard MacCutchan 22-Dec-16 4:08am    
As I said above, you cannot use cin to read from a remote client. It needs to take input via a web page or other socket connected interface.
Tashifa 22-Dec-16 4:33am    
how about something like this http://cpp.sh/
It takes user input through cin, I'm also trying to do something like this
Richard MacCutchan 22-Dec-16 6:58am    
No, it does not take user input through cin, it is a web page and uses Javascript, AJAX etc.

1 solution

It is the typical scenario for some client server architecture like in this example. Another example from Microsoft.

An important problem is security: so encrypt data someday and an user/password store is needed.
 
Share this answer
 
Comments
Tashifa 22-Dec-16 4:33am    
Thank you!
I'll check them out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900