-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 ?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.