1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| #include<iostream>
#include<fstream>
#include<stdlib.h>
#include<unistd.h>
#include<errno.h>
#include <sys/types.h>
using namespace std;
extern int errno;
int main(int argc, char **argv)
{
int i;
double aa,bb,cc,dd,ee,ff,gg,hh,d,q;
d=1.122965;
q=0.042412;
fstream azerty("test.txt",ios::out);
azerty.close();
for (i=0;i<5;i++)
{
fstream test("test.idl",ios::out);
test <<".r CALCCAUSTICS" <<endl;
test <<"CRITICS,"<<d<<","<<q<<""<<endl;
test <<"exit"<<endl;
test.close();
execlp("idl","idl","test.idl",NULL);
pid_t pid = fork();
if (pid < 0)
;//erreur
else if (pid = 0) //processus fils
{
execlp("idl","idl","test.idl",NULL);
exit 0 ;
}
else
{
wait(NULL); //on attend la fin du fils.
}
ofstream val("test.txt",ios::app);
fstream read("caustics.txt",ios::in);
read>>aa>>bb;
read>>cc>>dd;
read>>ee>>ff;
read>>gg>>hh;
val<<ee<<" "<<bb<<endl;
read.close();
val.close();
q=q+q/100;
}
cout <<argc<<" "<<argv[1]<<" "<<errno<<endl;
int retour = execlp("idl","idl","test.idl",NULL);
printf("%d", retour);
cout<<endl;
return 0;
} |
Partager