line numbers question

This is a discussion on line numbers question within the C++ Programming forums, part of the General Programming Boards category; this might b a silly question but is there a way to insert line numbers on my progs? im studying ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    494

    line numbers question

    this might b a silly question but is there a way to insert line numbers on my progs?

    im studying from this book and every prog has numbered lines so when u read the explantion u can follow it very easy lol so anyway i can add number lines in a way that it wont matter for the prog, not sure if im making myself clear here.

    thanks in advance eheh

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    I'm thinking you could make a macro to do it:
    Code:
    #define L(x)
    
    L(1) int main()
    L(2) {
    L(3) return 0;
    L(4) }
    However that seems like a lot of trouble. It may not be worth your time.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    What editor are you using? In most editors there is a way to display line numbers or at least see what line you are on.

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    In most editors there is a way to display line numbers or at least see what line you are on.
    That's true, but I think InvariantLoop needs the line numbers to correspond exactly to those in the book. Unless you enter the program in exactly as written, that wont happen. Usually when I do that, it doesn't correspond. However, I guess it's possible.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #5
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    Another not so great way:
    Code:
    /*  1*/ int main()
    /*  2*/ {
    /*  3*/     return 0;
    /*  4*/ }
    Then use a macro or script to update them as necessary.

  6. #6
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    I would suggest not trying to get the numbers to show up, because then you may start to develop a dependency on them. I think it's much better to train yourself to simply remember where a block of code should be found, or comment well.

  7. #7
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    I would suggest not trying to get the numbers to show up, because then you may start to develop a dependency on them. I think it's much better to train yourself to simply remember where a block of code should be found, or comment well.
    I agree. It's not really going to hold you back at all.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  8. #8
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    cool cool, thanks for the tip, i find it a bit distracting reading the book(they only say in this line blah blah this happens) and then looking at the monitor to find exact code. but better learn now than try to un-learn a bad habit later on.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help again with scrolling without wrapping
    By Dukefrukem in forum C Programming
    Replies: 8
    Last Post: 09-21-2007, 01:48 PM
  2. Need help with reading numbers from the command line
    By Nterpol in forum C Programming
    Replies: 4
    Last Post: 06-01-2006, 02:40 AM
  3. Command line argument question
    By Axel in forum C Programming
    Replies: 4
    Last Post: 10-13-2005, 04:01 AM
  4. command line arguments question
    By bazzano in forum C Programming
    Replies: 2
    Last Post: 09-29-2005, 01:56 PM
  5. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 06:38 PM

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