When I try to compile C file with a correct syntax using shell_exec()
function its work fine, but the problem is when I do a mistake in the C syntax. I can't get the error message from the output
php code :
<?php
echo shell_exec("gcc C:\\xamppp\\htdocs\\testor\\filec.c -o C:\\xamppp\\htdocs\\testor\\filec.exe");
?>
filec.c code :
#include <stdio.h>
int main(){
print("hello C!");//i wrote print to get an error message
}
cmd command :
**gcc filec.c -o filec.exe**
filec.c: In function 'main':
filec.c:3:1: warning: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
3 | print("hello C!");
| ^~~~~
| printf
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\escanor\AppData\Local\Temp\ccgCM4xv.o:filec.c:(.text+0x16): undefined reference to `print'
collect2.exe: error: ld returned 1 exit status
but nothing displayed in the browser.