Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to count the c++ file code lines?

How to count the c++ file code lines?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++tutorial
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    roboo
    wrote on last edited by
    #1

    How can I count the comment lines,function numbers and function lines in C/C++ file. I am I,Who is who,I am who,Who am I

    C C 2 Replies Last reply
    0
    • R roboo

      How can I count the comment lines,function numbers and function lines in C/C++ file. I am I,Who is who,I am who,Who am I

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Use GetLine to read a line at a time, then parse each string for comments or function declarations, etc. I'd do it in C#, because then you can use Regular Expressions, which would have to help. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

      R 1 Reply Last reply
      0
      • C Christian Graus

        Use GetLine to read a line at a time, then parse each string for comments or function declarations, etc. I'd do it in C#, because then you can use Regular Expressions, which would have to help. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

        R Offline
        R Offline
        roboo
        wrote on last edited by
        #3

        Really??I want to use the regular Expression too.But I am not familar with it.Can you show me the example. By the way,I can use the regular expression in VC6 ,so I do't have to use C# I am I,Who is who,I am who,Who am I

        C 1 Reply Last reply
        0
        • R roboo

          Really??I want to use the regular Expression too.But I am not familar with it.Can you show me the example. By the way,I can use the regular expression in VC6 ,so I do't have to use C# I am I,Who is who,I am who,Who am I

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          roboo wrote: I want to use the regular Expression too.But I am not familar with it. At it's simplest, a regular expression is like when you search for a file and type *.txt to get a text file - the * stands for any number of characters. RegEx can be a lot more complex, the MSDN is full of examples. C++ does not support RegEx natively, the .NET framework does. If you have VC6 it may not be worth the effort of finding something you can plug in to do it for you, although it's possible that Boost has something ( www.boost.org ). The C# compiler is free from Microsoft and there are some open source, free IDE's, so it's not entirely out of the question to give C# a go. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

          R 1 Reply Last reply
          0
          • C Christian Graus

            roboo wrote: I want to use the regular Expression too.But I am not familar with it. At it's simplest, a regular expression is like when you search for a file and type *.txt to get a text file - the * stands for any number of characters. RegEx can be a lot more complex, the MSDN is full of examples. C++ does not support RegEx natively, the .NET framework does. If you have VC6 it may not be worth the effort of finding something you can plug in to do it for you, although it's possible that Boost has something ( www.boost.org ). The C# compiler is free from Microsoft and there are some open source, free IDE's, so it's not entirely out of the question to give C# a go. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

            R Offline
            R Offline
            roboo
            wrote on last edited by
            #5

            Thank you very much again. Can you tell me where can I find the example code either C++ or C#. I am I,Who is who,I am who,Who am I

            C 1 Reply Last reply
            0
            • R roboo

              Thank you very much again. Can you tell me where can I find the example code either C++ or C#. I am I,Who is who,I am who,Who am I

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              MSDN is full of RegEx code, I have some articles on CP about iostreams ( which is how you read and write files ), apart from that I guess your options include string mashing, if you're using MFC then CString is the best string class to do that sort of stuff, unless you want to write funky STL functors for std::string. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

              R 1 Reply Last reply
              0
              • C Christian Graus

                MSDN is full of RegEx code, I have some articles on CP about iostreams ( which is how you read and write files ), apart from that I guess your options include string mashing, if you're using MFC then CString is the best string class to do that sort of stuff, unless you want to write funky STL functors for std::string. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

                R Offline
                R Offline
                roboo
                wrote on last edited by
                #7

                I think you had misunderstood me.I know how to use regular expression. I just want to know how to judge the "/**/" "//" "{}" string by regular expression.I cannot write the correct and workable expression. I am I,Who is who,I am who,Who am I

                C 1 Reply Last reply
                0
                • R roboo

                  I think you had misunderstood me.I know how to use regular expression. I just want to know how to judge the "/**/" "//" "{}" string by regular expression.I cannot write the correct and workable expression. I am I,Who is who,I am who,Who am I

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  Ah... I see. To be honest, I need to look up MSDN myself to build them, I'm not that experienced. The MSDN docs are very good though, I just don't know the stuff well enough yet to do it without them. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

                  1 Reply Last reply
                  0
                  • R roboo

                    How can I count the comment lines,function numbers and function lines in C/C++ file. I am I,Who is who,I am who,Who am I

                    C Offline
                    C Offline
                    Chris Maunder
                    wrote on last edited by
                    #9

                    Go to the macros and add-ins section for some add-ins that do this (maybe not all you need - but a start) cheers, Chris Maunder

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups