2016-11-26 86 views
-2

声明:我不知道我在做什么&试图谷歌我的方式通过这个;无效使用非静态成员函数(while循环/无类/ wget popen)

编译错误;

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

Source Function;

#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; 
} 

不知道如果“源”是一个成员函数,当我没有它的成员类时它将是一个成员函数。

曾试图使“源”的指针(*源),参考源(&源),没有骰子...

感谢提前任何帮助。

+2

c_str - > c_str() –

回答

0

我想你的意思

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

给我8分钟,我会标记为答案....那么简单... 谢谢。 – Snow

+0

@Snow根本没有。 –

相关问题