Thread: numbered lines

  1. #1
    michele CD
    Guest

    numbered lines

    hi all
    trying to read from an external file and
    have each line numbered..
    (i can do it if the char exceed a certain number, cause then I start the new line myself)
    but how can i check if a sentence (line) does not reach my x characters
    but begins a newline anyway.
    In other words, how can i number lines cvonsecutively even if some are very short?

    am I making sense?
    Monsta

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    not really sure i understand what your after but i think one solution could be to read in the strings into a map<int,std::string> using the int as the line number and also the key to your string. Look up STL map if you are not familiar with it.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Your biggest project: how many lines have you written?
    By happyclown in forum A Brief History of Cprogramming.com
    Replies: 44
    Last Post: 04-29-2009, 07:30 AM
  2. Replies: 11
    Last Post: 10-07-2008, 06:19 PM
  3. Print out first N lines
    By YoYayYo in forum C Programming
    Replies: 1
    Last Post: 02-21-2008, 12:58 AM
  4. Reading lines from a file
    By blackswan in forum C Programming
    Replies: 9
    Last Post: 04-26-2005, 04:29 PM
  5. count only lines of code...
    By flightsimdude in forum C Programming
    Replies: 13
    Last Post: 09-23-2003, 07:08 PM