Thread: how do you read a whole line of text from a txt file

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    11

    how do you read a whole line of text from a txt file

    can someone please help me with this problem. i need to read the first line of text from a txt file then output it into another txt file, then do the next line of text and so fourth. i also have to number the lines like so "1: asdadasda /n 2: sasdasdad..." and if a line is over 50 chars long i need to put it into multiple lines but the multiple lines dont need to be numbered

    output is too look like this

    1: Thas if skjhf ieak
    2: asdkihjfnoe oi dio
    3: Thea ijs ufaio
    aksdi askjd oias knj
    4: askdjado ij and so fourth.

    please help i am so stuck and have been for like 3 hours

  2. #2
    Registered User
    Join Date
    Oct 2005
    Posts
    26

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    11

    Smile

    ty very much

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    I would use getline to read each line into a string, and if the string is longer than 50 characters you can break it up into pieces.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  3. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM