473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

C++ file problems

Hi there all you clever clever programmers.
I am a university student who's currently face deep in a group project
to create a program to control and display information from our flight
simulator. I am personally am in charge of drawing the pretty maps of
aircraft position, runway position etc.

Now over this weekend I have been coding my little heart out making a
lovely section of code that reads in various data from 2 files, one to
do with navigation beacons and one to do with runways.
But i have hit a stumbling block, my seperate functions to read in the
data from each file work perfectly : ON THEIR OWN. For some reason when
i run one of these functions (both of which use an 'ifstream' object
called 'infile' ; start with 'infile.open("beacons.txt");' and end with
'infile.close();') before the other the second time i try to use
infile.open it ends up lumping me with a get()pointer position of '-1'
! Does anyone have any clues why?

Mar 26 '06 #1
4 1267
Hi,

I am not completely sure, but I think you probably tried to read past end of
file in the first one after which the error bit is set.

Using then the same on the second still leaves the object in an error
condition. Usually it is nicer to use two different objects.

Regards, Ron AF Greve

http://moonlit.xs4all.nl

"Pete" <pi**********@hotmail.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
Hi there all you clever clever programmers.
I am a university student who's currently face deep in a group project
to create a program to control and display information from our flight
simulator. I am personally am in charge of drawing the pretty maps of
aircraft position, runway position etc.

Now over this weekend I have been coding my little heart out making a
lovely section of code that reads in various data from 2 files, one to
do with navigation beacons and one to do with runways.
But i have hit a stumbling block, my seperate functions to read in the
data from each file work perfectly : ON THEIR OWN. For some reason when
i run one of these functions (both of which use an 'ifstream' object
called 'infile' ; start with 'infile.open("beacons.txt");' and end with
'infile.close();') before the other the second time i try to use
infile.open it ends up lumping me with a get()pointer position of '-1'
! Does anyone have any clues why?

Mar 26 '06 #2
Pete wrote:
Hi there all you clever clever programmers.
I am a university student who's currently face deep in a group project
to create a program to control and display information from our flight
simulator. I am personally am in charge of drawing the pretty maps of
aircraft position, runway position etc.

Now over this weekend I have been coding my little heart out making a
lovely section of code that reads in various data from 2 files, one to
do with navigation beacons and one to do with runways.
But i have hit a stumbling block, my seperate functions to read in the
data from each file work perfectly : ON THEIR OWN. For some reason when
i run one of these functions (both of which use an 'ifstream' object
called 'infile' ; start with 'infile.open("beacons.txt");' and end with
'infile.close();') before the other the second time i try to use
infile.open it ends up lumping me with a get()pointer position of '-1'
! Does anyone have any clues why?


Do both use the same stream object? If yes, you must first reset the
stream's state, because if it has reached the end of file, your eof bit
will still be set after closing and re-opening. Alternatively, just use an
own ifstream for each of your functions.

Mar 26 '06 #3
Thanks a bunch for your advice.
Yes both do use the same object and unfortunately both have to use the
same stream object and unfortunately they have to beacause they both
share the functions for extracting the names, Latitudes and Longitudes
of the beacons (i suppose i could seperate them but i like the
simplicity of the previous method)

Mar 27 '06 #4
Pete wrote:
Thanks a bunch for your advice.
Yes both do use the same object and unfortunately both have to use the
same stream object and unfortunately they have to beacause they both
share the functions for extracting the names, Latitudes and Longitudes
of the beacons (i suppose i could seperate them but i like the
simplicity of the previous method)


Actually, I'd say it's simpler to create the stream within the function as
local variable. Anyway, you can reset the stream's state with
infile.clear().

Mar 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: HNguyen | last post by:
Hi, I have a Web application in ASP.NET. My Application allows the users upload files into the server after checking their user names and passwords. For each transaction, the Web program will...
12
by: Brian Henry | last post by:
first question... I have a flat file which unfortinuatly has columns seperated by nulls instead of spaces (a higher up company created it this way for us) is there anyway to do a readline with this...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
5
by: Claudio Grondi | last post by:
I have just started to play around with the bsddb3 module interfacing the Berkeley Database. Beside the intended database file databaseFile.bdb I see in same directory also the __db.001...
7
by: ashley.ward | last post by:
We have been using VB6 to develop small custom apps that access an Oracle database, in order to extend a larger product that is developed by our colleagues in Germany (who use C++ and Java). As...
2
by: Jack Fox | last post by:
We are encountering a couple of problems with our ASP.NET / IIS 6.0 applications: In each of 3 production environments we maintain a Windows Server 2003 machine running NTFS as a file server....
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
29
by: list | last post by:
Hi folks, I am new to Googlegroups. I asked my questions at other forums, since now. I have an important question: I have to check files if they are binary(.bmp, .avi, .jpg) or text(.txt,...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.