Thread: reading lines

  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...


  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-21-2008, 12:58 AM
  3. A problem with reading multiple lines from a file
    By edd1986 in forum C++ Programming
    Replies: 6
    Last Post: 03-19-2006, 01: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