By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

reading data problems

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Yesim" <ye********@yahoo.com> wrote in message
news:c0**************************@posting.google.c om...
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
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.