非静态成员函数的使用无效(while loop/no class/wget popen)

invalid use of non-static member function (while loop/no classes/wget popen)

本文关键字:no loop class wget popen while 函数 静态成员 无效      更新时间:2023-10-16

免责声明:我不知道自己在做什么&试图通过此操作来搜索我的方式;

编译器错误;

main.cpp: In function ‘int sourcePull()’:
main.cpp:35:28: error: invalid use of non-static member function
   system(command.c_str + source);
                          ^

源函数;

#include <cstdio>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int sourcePull()
{
string source;
string command;
command = "wget -np -a source.log ";
ifstream sourceFile ("sources.txt");
if (sourceFile.is_open())
{
    while (sourceFile.good())
    {
        while (sourceFile >> source)
        {
            //system(command.c_str + source);
            FILE* file = popen(command.c_str + source, "r");
        }
        sourceFile.close();
    }
}
return 0;
}

当我没有课程作为成员时,"源"将如何成为成员函数。

尝试将"源"作为指针(*源),引用源(&amp; source),没有骰子...

感谢提前的任何帮助。

我认为你的意思是

FILE* file = popen((command.c_str() + source).c_str(), "r");
                               ^^^^