Thread: Go to the begining of file (new one)

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    4

    Unhappy Go to the begining of file by same pointer

    if i write c++ like this code, write the value to file.
    Then,how can i set the pointer back to the beginning of file that i have just written it.

    Code:
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    int main()
    {
    	int a = 10;
    
    	fstream aTa("Data_Check.txt",ios::out);
    	for(int i=0;i<a;i++0)
    		aTa << i;
    
    	return 0;
    }
    Last edited by Downnin; 08-27-2005 at 01:28 PM.

  2. #2
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    For writing, use seekp.

    Code:
    aTa.seekp( 0, ios_base::beg );
    For reading, use seekg.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM