reading data problems

Discussion in 'C++' started by Yesim, May 23, 2004.

  1. Yesim

    Yesim Guest

    Hello,

    I am trying to read two-dimensional float data into C++, but am
    getting a segmentation fault error message. This happens in g++
    compiler versions 2.95.2 and 3.1, but not on version 3, each in three
    different servers. I need to compile in the latest version. Below I
    attach the beginning of the code giving the problem:

    # include <iostream>
    # include <fstream>

    int main()
    {
    std::ifstream input ; (this is where the problem occurs, i then
    go on)

    ...

    input.open("filename") ;

    ...

    }

    and so on. Is there a more general/accepted way to do this? Please let
    me know if you need more detail. Thanks a lot,
    Yesim
    Yesim, May 23, 2004
    #1
    1. Advertising

  2. Yesim

    Mike Wahler Guest

    "Yesim" <> wrote in message
    news:...
    > Hello,
    >
    > I am trying to read two-dimensional float data into C++, but am
    > getting a segmentation fault error message. This happens in g++
    > compiler versions 2.95.2 and 3.1, but not on version 3, each in three
    > different servers. I need to compile in the latest version. Below I
    > attach the beginning of the code giving the problem:


    Why just the 'beginning?'. It would help us help you
    better if you'd post the smallest, complete, compilable
    program that exhibits the problem.

    >
    > # include <iostream>
    > # include <fstream>
    >
    > int main()
    > {
    > std::ifstream input ; (this is where the problem occurs, i then
    > go on)


    What problem? Does a 'segmentation fault' occur at this
    point? How do you know?

    Your code to this point is perfectly valid.

    >
    > ...
    >
    > input.open("filename") ;


    This line is OK too. (But you should check the stream
    state before attempting to read from the file).

    >
    > ...
    >
    > }
    >
    > and so on. Is there a more general/accepted way to do this?


    Do what? All your posted code does is create a stream
    object and attempt to open a file. What you have is the way
    to do it.

    >Please let
    > me know if you need more detail. Thanks a lot,


    We need a complete program, and a more specific description
    of what it's supposed to do, and what it actually does.

    -Mike
    Mike Wahler, May 23, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darrel
    Replies:
    3
    Views:
    650
    Kevin Spencer
    Nov 11, 2004
  2. Dimitri Papoutsis

    Problems with reading binary data files

    Dimitri Papoutsis, Mar 10, 2005, in forum: C++
    Replies:
    4
    Views:
    381
    Old Wolf
    Mar 11, 2005
  3. Stuart Clarke
    Replies:
    1
    Views:
    70
    Robert Dober
    Dec 7, 2008
  4. Stephen Moon

    reading output file data as input data

    Stephen Moon, Feb 28, 2004, in forum: Perl Misc
    Replies:
    5
    Views:
    161
    Tad McClellan
    Feb 29, 2004
  5. Replies:
    5
    Views:
    62
    Chris Angelico
    May 14, 2014
Loading...

Share This Page