Using Vectors vs. Arrays

Discussion in 'C++' started by ucfcpegirl06, Sep 25, 2006.

  1. ucfcpegirl06

    ucfcpegirl06 Guest


    I have a file that I am reading date from.

    File format is as follows:

    a 556644f3
    b 44545351

    I want to read the entire contents of this file into a 2-D array or

    I'd like to use vectors because it easily allows me to do what I need
    to with this data.

    My question is there are a lot of these data entries in this file and I
    don't know how many.

    I want to dynamically create this array or vector with this data with
    the row being 1 data entrie and the columns being the number of entries
    there are.

    How do I do this using vectors?
    ucfcpegirl06, Sep 25, 2006
    1. Advertisements

  2. ucfcpegirl06

    Daniel T. Guest

    Wrap a vector into a 2D array class. There is a start of one on the FAQ:
    Daniel T., Sep 25, 2006
    1. Advertisements

  3. ucfcpegirl06

    Jerry Coffin Guest

    class line {
    char a;
    int b;

    std::vector<line> lines;

    std::ifstream infile("file");

    std::istream_iterator<line> data(infile), end;

    std::copy(data, end, std::back_inserter(lines));
    Jerry Coffin, Sep 27, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.