shell script如下:
1
2 #!/bin/bash
3 for param1 in 2.5 3.0
4 do
5 ./main
6
7 done
main.cpp如下:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
double param1;
cin>>param1;
ofstream dd("data.txt",ios::out);
if(!dd)
{
cout<<"fail to open data.txt\n";
exit (0);
}
dd<<param1;
dd.close();
return 0;
}
就是说,在shell script的第六行应该跟什么命令,可以把定义的参数给main?