472,992 Members | 3,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

File's Openmode and the Cursor position

I hope everybody is having a fantastic X-Mas, I will hate you for that
since I have to be at the computer trying to keep my current job, grrr.
:)
OK, folks, jokes aside I have a question that might sound a bit dumb,
but I am just trying to confirm something, here I go. When opening a
'std::fstream' with the following mode:
std::ios_base::out | std::ios_base::app
I expect the cursor position at the end of the file, am I right here?

I am asking 'cos after I open the file stream, I retrieve its cursor
position which is always at zero; no matter what the size of the file
is.
I have overcome the problem by finding the file size and then setting
the cursor at the end of the file, but this would be a work around. The
proper way would be for the 'std' to place the cursor at the end of the
file, since the file has been opened for writing, no?

Gracias muchacho y muchachas, party on!

Dec 28 '05 #1
3 2232
Al-Burak wrote:
I hope everybody is having a fantastic X-Mas, I will hate you for that
since I have to be at the computer trying to keep my current job, grrr.
:)
OK, folks, jokes aside I have a question that might sound a bit dumb,
but I am just trying to confirm something, here I go. When opening a
'std::fstream' with the following mode:
std::ios_base::out | std::ios_base::app
I expect the cursor position at the end of the file, am I right here?

I am asking 'cos after I open the file stream, I retrieve its cursor
position which is always at zero; no matter what the size of the file
is.
I have overcome the problem by finding the file size and then setting
the cursor at the end of the file, but this would be a work around. The
proper way would be for the 'std' to place the cursor at the end of the
file, since the file has been opened for writing, no?

Gracias muchacho y muchachas, party on!

Hi,

Could you please show us the code you have, which does not work as you
expect?

Regards,
Peter Jansson
Dec 28 '05 #2
pH
You may find that even though the cursor position does not appear to be
at the end, writing to the file causes the data to be written after the
rest of the file, even without you explicity seeking to the end.

But, as Peter says, post some code !

Dec 28 '05 #3
Al-Burak wrote:
'std::fstream' with the following mode:
std::ios_base::out | std::ios_base::app
I expect the cursor position at the end of the file, am I right here?


No, you are not right. The mode 'app' causes the stream to append to
the file but it does not necessarily cause positioning the current
position to the end. This is what 'ate' is for: this mode puts the
initial position at the end of the file. Possibly you want a combination
of 'ate' and 'app' but actually why bother with the position at all?
'app' should always append to the file independent of what the initial
file position is. What is your actual problem?
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence
Dec 28 '05 #4

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

Similar topics

10
by: Steve | last post by:
Hi, I'm trying to read a binary file into a buffer: std::ifstream ifs(fileName, std::ios::in|std::ios::binary); if (!ifs) return; ifs.seekg(0,std::ios::end); int len = ifs.tellg();...
11
by: Skc | last post by:
I have a .txt which has been exported as a .csv from an external source. What i need to do is to import this into SQL2000 (into a table) but I need to do special things on the data: 1. I need to...
1
by: Dan H. | last post by:
Hello, I want to try to retrieve the cursor position x and y relative to the form the cursor is over. The way I am doing it now is: 1. Retrieve the left and top position of the form relative...
1
by: Tantra Veda | last post by:
Hello C# gurus, I have a question about finding cursor position in NumericUpDown control. On my form I have a numericUpDown control with 2 decimal places. I want to increment value in the numeric...
1
by: objectref | last post by:
Hi to all, we have the MousePosition property that we can get the Point of the position of the mouse cursor on the screen, but is it there a way to get the respective Point of a cursor in a...
9
by: Sandy | last post by:
can mfc application, send text data to opened notepad file in desktop?(live transfer of data) . can anybody help
14
by: Gary Nelson | last post by:
Anyone have any idea why this code does not work? FileOpen(1, "c:\JUNK\MYTEST.TXT", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Shared) Dim X As Integer For X = 1 To 26 FilePut(1, Chr(X +...
12
by: imme929 | last post by:
How do I do it? Nothing in the books is helpful. I need to save a structure with different data types.
4
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.