C++从 PHP 获取变量

C++ get variable from PHP?

本文关键字:变量 获取 PHP C++      更新时间:2023-10-16

我创建了一个Web界面,允许用户选择一个txt文件。我的C++程序会去文件夹,根据用户选择的txt文件执行(基本上文本文件内容是关于配置的,所以程序需要根据用户在网页上的选择来加载配置(。现在的问题是,如何将文本文件名传递给cpp程序。我用粗体和斜体附加的编码是行不通的,只是我想存档的意图。

int main(***string filename***)
{
using namespace std;
vector<string> strings;
string path = "/home/pi/Desktop/DMixer_Webinterface_Downloadfile/";
string fullpath = path + ***filename***;
//  ifstream file("/home/pi/Desktop/DMixer_Webinterface_Downloadfile/abc_2017_03_10_23_24_52.txt");
ifstream file(fullpath);
std::string str;
while (std::getline(file, str, ','))
{
    myArray[array_count] = str; // store those value in array
                                //  cout << str << "n";
    strings.push_back(str);
    array_count++;
}
x_gap_value = atof(myArray[2].c_str());
y_gap_value = atof(myArray[3].c_str());
return 0;
}

只需将

string param

在你的主方法中,用一个带有参数的参数调用你的程序。

啧:

http://www.cplusplus.com/articles/DEN36Up4/