How can i compile c++ code in php with an external file as input and generate an output file.... i can compile it using exec("cl A.cpp") where A.cpp is the code file but i want to create A.out an output file with the help of A.cpp and A.in....

A.cpp
PHP Code:
#include<stdio.h>

int main(){
    
int n;
    while( 
scanf("%d", &n) ){
        if( !
)break;
        
printf("%d\n"n);
    } 
A.in
PHP Code:
1
2
3
4