error: 'ios_base' has not been declared

user3210574

I am using libcurl to download serialized code and bust it open but, I get an error that looks like fstream is missing but it is very much included. I looked around but very little on the error. Below is the error and code. What did miss?

compile error output

g++ -g testGetprice2.cpp -o testGetprice2.o -std=gnu++11 -lcurl
testGetprice2.cpp: In function 'int getData()':
testGetprice2.cpp:45:56: error: 'ios_base' has not been declared
testGetprice2.cpp:45:72: error: 'ios_base' has not been declared

code:

#include "rapidjson/include/rapidjson/document.h"
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <curl/curl.h>
#include <unistd.h>
#include <unordered_map>
#include <string>

using namespace rapidjson;

struct myData
{
        std::fstream *file;
        std::string *str;
};

size_t write_data(void *ptr, size_t size, size_t nmemb, myData *data)
{
        size_t numBytes = size * nmemb;

        if (data->file)
                data->file->write((char*)ptr, numBytes);

        if (data->str)
                *data->str += std::string((char*)ptr, numBytes);

        return numBytes;
}

//function to get coin data and perform analysis
int getData()
{
        int count = 0;

    //begin non terminating loop
        while(true)
        {
                count++;
                CURL *curl = curl_easy_init();
                if (curl)
                {
                        curl_easy_setopt(curl, CURLOPT_URL, "http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=155");

                        std::fstream file("/home/coinz/cryptsy/myfile.txt", ios_base::out | ios_base::ate);
                        std::string json;

                        myData data;
                        data.file = &file;
                        data.str = &json;

                        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write_data);
                        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);

                        /* Perform the request, res will get the return code */
                        CURLcode res = curl_easy_perform(curl);

                        /* Check for errors */
                        if (res != CURLE_OK)
                        {
                                std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
                        }
                        else
                        {
                                file << std::endl;

                                //begin deserialization
                                Document document;
                                document.Parse(json.c_str());
                                assert(document.HasMember("lasttradeprice"));
                                assert(document["hello"].IsString());
                                std::cout << "The Last Traded Price is = " << document["lasttradeprice"].GetString() << std::endl;
                        }

                        /* always cleanup */
                        curl_easy_cleanup(curl);
                }

                //timer for URL request.  *ADUJST ME AS DESIRED*
                usleep(10000000);
        }

        return 0;
}

//Le Main
int main(void)
{
    getData();
}
steryd

ios_base is in namespace std. Add prefix std:: before ios_base.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Bool has not been declared

From Dev

Namespace has not been declared

From Dev

Member "has already been declared" error with CUDA and Eigen

From Dev

C++, error: '__locale_t' has not been declared

From Dev

"Error: '::hypot' has not been declared" in cmath while trying to embed Python

From Dev

C++ make error: object_var has not been declared

From Dev

build insert statement error Https has already been declared

From Dev

C++ Compile error on NetBSD '::system' has not been declared

From Dev

ERROR: 'Namespace for prefix 'xsi' has not been declared.'

From Dev

The field was declared on serializer , but has not been included error in django rest

From Dev

When the destroy() has been declared?

From Dev

When the destroy() has been declared?

From Dev

Debian Jessie 8.9 Compiling Error for Cryptocoin Wallets "error: ‘::SSLv3_server_method’ has not been declared"

From Dev

::write() and ::read() has not been declared error. Qt5 UNIX signal handling

From Dev

g++10, C++20, boost 1.75.0 :: error: 'awaitable' has not been declared in 'boost::asio'

From Dev

GCC does not throw an error during the compiler stage when a function has not been forward declared

From Dev

silly C++ syntax has not been declared

From Dev

Undeclared variable in C while it has been declared

From Dev

Browser: Identifier X has already been declared

From Dev

boost:asio ::UnregisterWaitEx has not been declared

From Dev

Assigning a variable to a textBox once it has been declared

From Dev

"The global element ... has already been declared" errors

From Dev

Variable X has been used before it's been declared

From Dev

Action has no declared type error

From Dev

How to initialize NumericVector to a specific size after it has been declared?

From Dev

Is there any way to check whether a function has been declared?

From Dev

How to know if a variable has been declared in Babel 6

From Dev

why can I return a function before it has been declared in javascript?

From Dev

How to check if variable has been declared, although uninitialized?

Related Related

  1. 1

    Bool has not been declared

  2. 2

    Namespace has not been declared

  3. 3

    Member "has already been declared" error with CUDA and Eigen

  4. 4

    C++, error: '__locale_t' has not been declared

  5. 5

    "Error: '::hypot' has not been declared" in cmath while trying to embed Python

  6. 6

    C++ make error: object_var has not been declared

  7. 7

    build insert statement error Https has already been declared

  8. 8

    C++ Compile error on NetBSD '::system' has not been declared

  9. 9

    ERROR: 'Namespace for prefix 'xsi' has not been declared.'

  10. 10

    The field was declared on serializer , but has not been included error in django rest

  11. 11

    When the destroy() has been declared?

  12. 12

    When the destroy() has been declared?

  13. 13

    Debian Jessie 8.9 Compiling Error for Cryptocoin Wallets "error: ‘::SSLv3_server_method’ has not been declared"

  14. 14

    ::write() and ::read() has not been declared error. Qt5 UNIX signal handling

  15. 15

    g++10, C++20, boost 1.75.0 :: error: 'awaitable' has not been declared in 'boost::asio'

  16. 16

    GCC does not throw an error during the compiler stage when a function has not been forward declared

  17. 17

    silly C++ syntax has not been declared

  18. 18

    Undeclared variable in C while it has been declared

  19. 19

    Browser: Identifier X has already been declared

  20. 20

    boost:asio ::UnregisterWaitEx has not been declared

  21. 21

    Assigning a variable to a textBox once it has been declared

  22. 22

    "The global element ... has already been declared" errors

  23. 23

    Variable X has been used before it's been declared

  24. 24

    Action has no declared type error

  25. 25

    How to initialize NumericVector to a specific size after it has been declared?

  26. 26

    Is there any way to check whether a function has been declared?

  27. 27

    How to know if a variable has been declared in Babel 6

  28. 28

    why can I return a function before it has been declared in javascript?

  29. 29

    How to check if variable has been declared, although uninitialized?

HotTag

Archive