We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,605 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to make an evaluator

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! :)

2
Contributors
2
Replies
1 Hour
Discussion Span
1 Year Ago
Last Updated
3
Views
SoapyCro
Newbie Poster
11 posts since Mar 2012
Reputation Points: 11
Solved Threads: 0
Skill Endorsements: 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.

ilearnz001
Newbie Poster
11 posts since Jan 2012
Reputation Points: 11
Solved Threads: 1
Skill Endorsements: 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.. :)

SoapyCro
Newbie Poster
11 posts since Mar 2012
Reputation Points: 11
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0590 seconds using 2.66MB