How to use gcc as a compiler for code written in a programming game

Im creating a C programming game where player write code to solve problems, puzzles, etc. My main problem is how do I compile the code that players have written in game. Someone suggested to me to use gcc as the compiler, problem is I dont realy know how to implement it with UE4. My plan now is just to save the text/code that players write in a .c file and then compile that with probably gcc, and then just get the output to check their aswers for the questions.
I’ve hit a brick wall with how to implement this, which is a big problem considering that programming is the main game mechanic of this school project of mine, so I would appreciate any help you guys can give:D