C++如何将变量传递到函数中

C++ how to pass variable into function?

本文关键字:函数 变量 C++      更新时间:2023-10-16
void webparser()
{
    stringstream ss;
    ss << "lynx -dump 'http://somesite.com/q?s=" << currency << "=X' > file.txt";
    system(ss.str().c_str());
}

如果我想将 GBPUSD 用作 char chArray[],如何将例如"GBPUSD"传递到网络解析器中;然后在我的情况下将传递的值分配为可变货币

谢谢,不需要退货。

void webparser(const std::string& currency) {
  stringstream ss;
  ss << "lynx -dump 'http://somesite.com/q?s=" << currency << "=X' > file.txt";
  system(ss.str().c_str());
}

调用函数:

webparser("Hello, World!");