-1

I need a php script to compile C/C++ file. After compiling and getting the executable of that file i need to run that file with a argument of input.txt file and then compare the result with output.txt file

How can i do this ?

ruby
  • 1,497
  • 2
  • 10
  • 6

2 Answers2

1

Call a command-line C++ compiler using system, exec, or backticks. There is no C++ compiler written in PHP.

Sjoerd
  • 74,049
  • 16
  • 131
  • 175
0

Is PHP required? If not consider GNU Make. It was especially developed to solve such problems as your. With this simple Makefile:

OUT = app
CFLAGS = -O2 -Wall

$(OUT): main.o

clean:
        rm -rf $(OUT) main.o

You get ability to easy compile your program with different compiler flags and performing clean operations:

make           # for compiling
make clean     # for remove binaries

Make has a good manual. Also, there is similar tool from Microsoft called nmake.

Kirill
  • 3,364
  • 2
  • 21
  • 36