LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-01-2006, 06:41 AM   #16
Hivemind
Member
 
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30

I gave you a complete solution, try that you ungrateful moron.
 
Old 02-01-2006, 06:45 AM   #17
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
You should be using the << operator for cout...


graeme
 
Old 02-01-2006, 06:48 AM   #18
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
Quote:
Originally Posted by BenScaplen
There is an error because of the '>>' operator

error C2676: binary '>>' : 'class std::basic_ostream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to the predefined

could this be the problem?
I'm still guessing at the code you're using to get that error, but I think you need to do:

cout << indata.rdbuf();

Not:

indata >> cout;

This is because streams expects to work with data or stream-buffers, rather than a stream.
 
Old 02-01-2006, 06:54 AM   #19
BenScaplen
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
It output the proper pathway to the file
 
Old 02-01-2006, 07:00 AM   #20
BenScaplen
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Hivemind, still trying to make your code work for me. Trying to find out what is different so I can change mind. Thanks for the code, it does work.

any idea whats different from yours?
 
Old 02-01-2006, 07:38 AM   #21
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
There is quite a bit of code there and I'm not certain at which point you are getting the error. Can you tell us what error you are getting (i.e what gets printed out to the console), then we can see at which line this is being generated.

cheers,

graeme.
 
Old 02-01-2006, 07:46 AM   #22
BenScaplen
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
I am getting the error line
"Failed to get number of gridpoints"

That means that the is_open didn't cause an error. I changed the filename so that I tried to open a file that didn't exist and the is_open caused the problem. This could only mean that the Bonavista.con is actually opening. The problem has to be that it cannot read the file.

In addition to that I substituted Allroad.con where Bonavista.con was just to see if any file could be read, and it didn't work. But I already opened Allroad.con and got information from it. :P ahhhhh
 
Old 02-01-2006, 07:50 AM   #23
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
Quote:
Originally Posted by BenScaplen
I am getting the error line
"Failed to get number of gridpoints"

That means that the is_open didn't cause an error. I changed the filename so that I tried to open a file that didn't exist and the is_open caused the problem. This could only mean that the Bonavista.con is actually opening. The problem has to be that it cannot read the file.
yes.. i told you this with my first post in this thread..

did you try hiveminds solution on your original datafiles in their original locations?
 
Old 02-01-2006, 08:01 AM   #24
Hivemind
Member
 
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30
Opening a file, reading a name from it, then closing the file and open a new file with the name read is trivial. And it's all in my code.
 
Old 02-01-2006, 08:07 AM   #25
Hivemind
Member
 
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30
Divide and conquer is the key to successful programming, and it's clear you haven't done that. First you should write a function that opens the allroad.con file. When you have *tested* that it works, extend the function to read a file name. When you have *tested* that it can read the name, you close the file (if you don't need it anymore), then the next step is to write a function that opens a file with name that you just read. Then you test that and the next step is to test if you can read from the second file and so forth. Divide and conquer. Build your program from nothing to completeness by adding small parts (modules, functions, classes whatever) that can be tested independently. Each time you add something, you test again to see if it works. That way you see what's working and what's not.
 
Old 02-01-2006, 08:33 AM   #26
BenScaplen
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Hivemind thats what I was doing.
Testing every step of the way, each time I would test to make sure each piece of data was collected.

Thanks for you time and help guys.

Solution: When I would close the first file data would stay on the stream. To solve this I used the clear function and it worked. I figured it out by adding a second ifstream called inData2 and it worked. But hivemind you only used one ifstream so...who knows. Maybe you now know what I was doing wrong? was the close() working properly?
 
Old 02-01-2006, 08:42 AM   #27
Hivemind
Member
 
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30
If the fail bit is set all ops except clear are no-ops until the fail bit has been cleared. But you shouldn't have to get into a situation where the fail bit is set if you perform your reads and writes properly.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
(quick!) ifstream problem Liche Programming 1 10-04-2005 06:55 PM
awk: fatal:cannot open file for reading (no such file or Directory) in Linux sangati vishwanath Linux - Software 4 07-06-2005 12:59 AM
problem reading arabic file names in fedora core 3 Yaan Linux - Newbie 1 05-21-2005 01:44 PM
ifstream - Problem siemens Programming 2 05-13-2005 01:25 PM
problem in reading Microsoft word as a binary file ljqu_happy Programming 15 02-02-2005 10:10 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration