f.seekg(0, ios::beg)

Posted on 2004-10-28
Last Modified: 2008-01-09
What is the role of  f.seekg(0, ios::beg);
Even if i remove from my read function it does not hurt.
Question by:komlaaa
    1 Comment
    LVL 5

    Accepted Solution

    f.seekg sets the read/write position in a file.

    f.seekg(0, ios::beg)  will set the read position to 0 bytes from the begining
    of the file f, exactly at the start. however when you open a file in a non-append
    mode (like for reading or writing), the  read position is always at the start. so you
    can remove this line without affecting the behaviour of the function in your case.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
    This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
    The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now