Im working on a small problem. I am new to C. The issue I am having is reading urls from a file to be used with CURLOPT_URL. i don't seem to be able to do it. In the example code below i have used "http://10.10.10.10/" this is where i would like to have urls loaded from a file... I have tried fgets to read line and have "line" assigned were "http://10.10.10.10/" is in the example.

        FILE* fp;
        char buffer[255];
        fp = fopen("file.txt", "r");

        while(fgets(buffer, 255, (FILE*) fp)) {
            CURLM *m_curl;
            CURLMcode res;
            m_curl = curl_multi_init();
            curl_multi_setopt(m_curl, CURLMOPT_PIPELINING, 1L); 

            CURL *curl[MAX_PIPELINE_REQ];

            for(i=0; i<pipeline_req; i++){ 
                curl[i] = curl_easy_init();
                if(!curl[i])
                    err("Something went wrong", 0);
                res = curl_easy_setopt(curl[i], CURLOPT_URL, buffer);

0 Answers