Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (walters):

hey ,I am working on my project(3rd year) i want my application(desktop) to have a function where it judges answers of the users based on the programming language he/she chose i.e c++ and java .The users will submit answers(code) online and get the answer after some seconds if the answer is write it must give the output CORRECT if it is wrong it must write INCORRECT .I don't know whether there is free compiler that can do so,if it is there can u pls tell me about it or send me a link .OR if u have alternative way to do this can u pls help me.thnx

OpenStudy (walters):

@ajprincess

OpenStudy (anonymous):

One way to do this would be to save the answer in a file. Then, have your program call a compiler suitable for the language and call the compiled program with known inputs. After that, you can compare the results with the correct results and output the Correct/Incorrect message (with maybe some hints why the result is incorrect). Most programming languages allow you to call external programs, so it shouldn't be a big problem.

OpenStudy (walters):

which compiler will i be using ?

OpenStudy (poopsiedoodle):

What language are you writing it in?

OpenStudy (walters):

c#

OpenStudy (poopsiedoodle):

What operating system do you use?

OpenStudy (walters):

windows

OpenStudy (poopsiedoodle):

but like... XP, Vista, 7, or 8?

OpenStudy (walters):

windows 7

OpenStudy (walters):

@poopsiedoodle ,the link u gave me it seems they don't give wat i need ,maybe my question is not clear

OpenStudy (poopsiedoodle):

I was answering your question about the compiler.

OpenStudy (walters):

@slotema @poopsiedoodle . i want to compile the source code of the user on my application ,not his/her final output but the source code and there after if the the code contains no error then write correct else incorrect

OpenStudy (poopsiedoodle):

Oh. I have no idea then.

OpenStudy (anonymous):

I'm not sure about C#, but C/C++ have a function called 'system' (in stdlib.h), which allow you to execute system programs. You should try something similar to this: dump_user_source( "tmpfile.c" ); system( "gcc -o a.out tmpfile.c" ); system( "./a.out output.txt" ); compare_results( "output.txt" ); (for a C# version of 'system', see e.g. http://stackoverflow.com/questions/10806427/c-system-in-c-sharp )

OpenStudy (walters):

ok i get it. but System("gcc -o a.out tmpfile.c"); how am i going to get gcc should i download it first or what.if is by download pls give me the best link for it.

OpenStudy (anonymous):

So the line "gcc -o a.out tmpfile.c" is just how I normally would call my compiler from the command line. You can use GCC for your project (see e.g. http://gcc.gnu.org/install/specific.html#windows on how to get it), but you don't have to. My guess would be that you're using Visual Studios to compile your code. There are also ways to compile a file with that compile (see e.g. http://msdn.microsoft.com/en-us/library/f35ctcxw.aspx ). Suppose you use the cl.exe compiler, you'd call something like `system( "cl.exe tmpfile.c");` plus whatever options you need.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!