Snow Snow - 1 year ago 115
C++ Question

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

Disclaimer: i have no clue what i'm doing & trying to google my way through this;

Compiler Error;

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");

return 0;

not sure how "source" would be a member function when I have no classes for it to be a member of.

Have tried making "source" a pointer (*source), referencing source (&source), no dice...

Thanks for any help in advance.

Answer Source

I think you mean

FILE* file = popen((command.c_str() + source).c_str(), "r");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download