reading lines

This is a discussion on reading lines within the C++ Programming forums, part of the General Programming Boards category; Is it possible to get a program to read certain lines (or any lines) of a text file and store ...

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001

    Thumbs up reading lines

    Is it possible to get a program to read certain lines (or any lines) of a text file and store it in a variable? If so, how is this done? I'd post some code, but I can't think of anything to put in it other than what I need to know...

    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  2. #2
    Registered User
    Join Date
    Sep 2001
    hrmm from what i understand you want to take a text file and store each line as a string..

    so you would probably have to use 2 dimensional arrays. for ex:

    int col=0;
    int row=0;

    char line[200][80];

    this would hold 80 chars per line for 200 lines.
    then you would do something like this:

    if(line[row][col] == '\n')
    row++;//goto next row
    col=0;//start at 0 col

    col++;//increment col
    input.get(line[row][col]);//get another char

    hope dat helps... prlly a better way than that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 10-07-2008, 06:19 PM
  2. Print out first N lines
    By YoYayYo in forum C Programming
    Replies: 1
    Last Post: 02-20-2008, 11:58 PM
  3. A problem with reading multiple lines from a file
    By edd1986 in forum C++ Programming
    Replies: 6
    Last Post: 03-19-2006, 12:26 PM
  4. Replies: 6
    Last Post: 05-12-2005, 03:39 AM
  5. Reading specific lines
    By Aristotle in forum C Programming
    Replies: 2
    Last Post: 04-12-2004, 04:34 PM

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