setting a file position pointer

This is a discussion on setting a file position pointer within the C++ Programming forums, part of the General Programming Boards category; Can you please tell me how I set the pointer in a text file to a particular position? I want ...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    96

    setting a file position pointer

    Can you please tell me how I set the pointer in a text file to a particular position?

    I want to set it at 150 and tried

    Code:
     ifstream jcin ( "Players.txt" );
     fseek ( jcin , 150 , SEEK_SET );
    But all I get is an error saying:
    Code:
    invalid conversion from 'void*' to 'FILE* {aka _iobuf*}' [-fpermissive]

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,451
    You should use seekg. Take care to open the file in binary mode though.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    96
    Thanks laserlight - easy when you know how isn't it?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,451
    Yeah, it is easy when you know how and where to look things up
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. setting cursor position
    By scrasnu in forum C Programming
    Replies: 1
    Last Post: 10-04-2008, 10:28 AM
  2. Getting and setting cursor position
    By Spartan552 in forum Linux Programming
    Replies: 8
    Last Post: 01-14-2008, 04:27 AM
  3. Savign the position of a pointer in an input file
    By earth_angel in forum C++ Programming
    Replies: 13
    Last Post: 07-08-2005, 03:39 PM
  4. Setting a pointer to file data
    By RobbieMc in forum C++ Programming
    Replies: 1
    Last Post: 03-19-2005, 10:29 AM
  5. Position FILE pointer to a specified line of Text file
    By jessica_xie in forum C Programming
    Replies: 2
    Last Post: 02-04-2005, 02:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21