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. run CMD tree command in c Language

run CMD tree command in c Language

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structuresquestion
6 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.
  • D Offline
    D Offline
    dipesh_karmakar
    wrote on last edited by
    #1

    I want to use the Windows CMD tree command in my C++ console application.it is possible ?

    enhzflepE 1 Reply Last reply
    0
    • D dipesh_karmakar

      I want to use the Windows CMD tree command in my C++ console application.it is possible ?

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #2

      Yes. It's both possible and very easy, as it turns out. Drawing on an old (and frowned-upon) practise of using a system call to clear the screen or wait for a keystroke,

      system("CLS");

      and

      system("PAUSE");

      You can achieve your aim using the system function. Just remember to use forward-slashes (/) in the path-name or to use double back-slashes (\\) E.g

      system("tree c:\\xampp");
      // or
      system("tree c:/xampp");

      D 1 Reply Last reply
      0
      • enhzflepE enhzflep

        Yes. It's both possible and very easy, as it turns out. Drawing on an old (and frowned-upon) practise of using a system call to clear the screen or wait for a keystroke,

        system("CLS");

        and

        system("PAUSE");

        You can achieve your aim using the system function. Just remember to use forward-slashes (/) in the path-name or to use double back-slashes (\\) E.g

        system("tree c:\\xampp");
        // or
        system("tree c:/xampp");

        D Offline
        D Offline
        dipesh_karmakar
        wrote on last edited by
        #3

        Error in code plz help me...

        #include<stdio.h>
        #include<conio.h>
        #include<dos.h>
        #include<windos.h>
        void main(){
        system("tree c:\\xampp");
        getch();
        }

        L 1 Reply Last reply
        0
        • D dipesh_karmakar

          Error in code plz help me...

          #include<stdio.h>
          #include<conio.h>
          #include<dos.h>
          #include<windos.h>
          void main(){
          system("tree c:\\xampp");
          getch();
          }

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Apart from the fact that you mis-spelt windows, what else is wrong?

          D 1 Reply Last reply
          0
          • L Lost User

            Apart from the fact that you mis-spelt windows, what else is wrong?

            D Offline
            D Offline
            dipesh_karmakar
            wrote on last edited by
            #5

            compilation Error is given : Unable to Open include File ''windows.h

            L 1 Reply Last reply
            0
            • D dipesh_karmakar

              compilation Error is given : Unable to Open include File ''windows.h

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              The code you showed above has it spelled as windos.h (missing the last w character). If it is spelled correctly then ensure you have set the path(s) foe the correct include directories. If you are using visual Studio then this should have been done for you at install time.

              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