getting the beginig of a line in a textfile

This is a discussion on getting the beginig of a line in a textfile within the C Programming forums, part of the General Programming Boards category; hi i trying to get from anywhere in text to the beginning of the line. i wrote this litle piece ...

  1. #1
    Registered User stormbringer's Avatar
    Join Date
    Jul 2002
    Posts
    90

    getting the beginig of a line in a textfile

    hi

    i trying to get from anywhere in text to the beginning of the line. i wrote this litle piece of code (just an extract from my prog):

    Code:
    while((tmppos!=apos) && (c=fgetc(fr))!='\n') {		
    						fseek(fr,-2,SEEK_CUR);
    						fgetpos(fr,&tmppos);
    					}
    in size_t apos is stored the begining of the text, to make sure i wont read to far. i need tmppos to check that.

    any idea?

    thanks

  2. #2
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    Why can't you just use fgets to read the entire line into a local buffer?
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing Length of Input and the Limited Input
    By dnguyen1022 in forum C Programming
    Replies: 33
    Last Post: 11-29-2008, 04:13 PM
  2. adding line numbers and concatenating a filename
    By durrty in forum C Programming
    Replies: 25
    Last Post: 06-28-2008, 04:36 AM
  3. Finding carriage returns (\c) in a line
    By JizJizJiz in forum C++ Programming
    Replies: 37
    Last Post: 07-19-2006, 06:44 PM
  4. Adding Line numbers in Word
    By Mister C in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 06-24-2004, 09:45 PM

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