Adding Line numbers in Word

This is a discussion on Adding Line numbers in Word within the A Brief History of Cprogramming.com forums, part of the Community Boards category; well looks like there have been 4 different methods posted... Perl, PHP, grep, and VB ... now go at it!...

  1. #16
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    well looks like there have been 4 different methods posted...

    Perl, PHP, grep, and VB...

    now go at it!
    My Website

    "Circular logic is good because it is."

  2. #17
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Quote Originally Posted by DavidP
    well looks like there have been 4 different methods posted...

    Perl, PHP, grep, and VB...

    now go at it!
    hmmm, interesting that 4 non-C/C++ solutions were posted at the c-board.

  3. #18
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    Code:
    #include <iostream>
    #include <fstream>
    #include <vector>
    #include <string>
    
    int main ( void )
    {
    	std::ifstream load ( "sourcefile.cpp" );
    
    	std::vector < std::string > lines;
    	std::string tempStr;
    
    	while ( !load.eof() )
    	{
    		getline(load, tempStr);
    		lines.push_back(tempStr);		
    	}
    
    	load.close();
    
    	std::ofstream save ( "sourcefile.cpp" );
    
    	for ( int k = 0; k < lines.size(); k++ )
    	{
    		save << (k + 1) << "\t" <<
    			lines[k] << "\n";
    	}
    
    	save.close();
    
    	return 0;
    }
    Solves that problem...
    My Website

    "Circular logic is good because it is."

  4. #19
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    Quote Originally Posted by Perspective
    hmmm, interesting that 4 non-C/C++ solutions were posted at the c-board.
    Hmm.. does that tell you anything about the worthiness of C/C++?

  5. #20
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Quote Originally Posted by ober
    Hmm.. does that tell you anything about the worthiness of C/C++?
    It's so pure that to be spoken in this thread would dishonor it - and the speaker?
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  6. #21
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    > Hmm.. does that tell you anything about the worthiness of C/C++?
    It tells you that many people have a lot more tools in the toolbox than some one-dimensional being who swears 'x' is best for everything.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #22
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    Salem is kickin'

    (according to his reputation bars)

    ....

    Meanwhile Prelude exudes kindness and good coding practice while Thantos apparently refers to himself as being special.
    My Website

    "Circular logic is good because it is."

  8. #23
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Just for the record I never rode ANY school buses!

  9. #24
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    RIGHT. Just short buses, huh?

  10. #25
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >Just for the record I never rode ANY school buses!

    You poor soul. I'm sorry you missed out on the adventure.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 04:06 PM
  2. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 06:49 PM
  3. adding odd numbers only
    By CheyenneWay in forum C++ Programming
    Replies: 12
    Last Post: 05-06-2004, 01:22 AM
  4. the definition of a mathematical "average" or "mean"
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 12-03-2002, 11:15 AM
  5. Line Numbers in VI and/or Visual C++ :: C++
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 02-10-2002, 10:54 PM

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