I’m new to C++, and I’m trying to read a string from a text file that only contains one string and use that as input for a system() call. Here’s what I have:
#include <iostream>
#include <string>
#include <fstream>
int main(int argc, const char * argv[])
{
std::string curlString = "/usr/bin/curl -O ";
std::ifstream file("/Users/test/Desktop/test.txt");
if (file) {
std::string line;
while (std::getline( file, line ));
system(curlString + line);
}
}
This is probably a complete and utter mess, so thanks so much for helping out, I really appreciate it.
Thanks in advance for any insight!
I am not sure what the problem really is. Is it the reading from the file? There are planty of example how to do this in stackoverflow. Why do you not do something like: