1,105,197 Community Members

How to make an evaluator

Member Avatar
SoapyCro
Newbie Poster
11 posts since Mar 2012
Reputation Points: 1 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hey all!
I was thinking about how to make a program, in which you write some c++ code and program tests that code with given examples.

For example you input following code in that program:

#include <iostream>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << a + b;
	return 0;
}

the program compiles and tests the code (for example it tests if you input 1 and 3, will 4 be written in console using that code) and gives you information if the program is working or not.

Or in other words, how to make program that compiles given code (using compiler, for example g++) and tests it.

Thanks! :)

Member Avatar
ilearnz001
Newbie Poster
11 posts since Jan 2012
Reputation Points: 1 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

g++ filename.cpp

will make a.out file.

to run a.out file type: ./a.out

file will run.

can make a pernimate file by typing:

g++ -o pernimatefile filenametocompile.cpp

>> will create a executable pernimatefile that wont be over writen everytime you
compile a different program.

Member Avatar
SoapyCro
Newbie Poster
11 posts since Mar 2012
Reputation Points: 1 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks. This is what I have now. test.cpp includes written code.

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    system("g++ -o -Wall C:\\Users\\%USERNAME%\\Documents\\test.cpp");
    system("g++ ./test.o");
}

How can I test that program with examples? Sorry for beeing "noob" but this is completely new field for me, I've never done anything like this before.. :)

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: