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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to clear the screen in DOS

How to clear the screen in DOS

Scheduled Pinned Locked Moved C / C++ / MFC
c++game-devhelptutorialquestion
5 Posts 5 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.
  • C Offline
    C Offline
    CreepingFeature
    wrote on last edited by
    #1

    :sigh: I am just starting with C++, and have a problem. I wrote a text game but the thing is some times I want the new question etc to start at the top of a clean black screen (that is erase all previous lines). I could just put a pile of endl; but a couple of days ago somewhere on the site I saw a clrScrn; statment or something like that and remembered BASIC. Could someone tell me the the #include and the correct way to use it. Thanks in advance!

    V T A A 4 Replies Last reply
    0
    • C CreepingFeature

      :sigh: I am just starting with C++, and have a problem. I wrote a text game but the thing is some times I want the new question etc to start at the top of a clean black screen (that is erase all previous lines). I could just put a pile of endl; but a couple of days ago somewhere on the site I saw a clrScrn; statment or something like that and remembered BASIC. Could someone tell me the the #include and the correct way to use it. Thanks in advance!

      V Offline
      V Offline
      V 0
      wrote on last edited by
      #2

      the DOS-command 'cls' clears the screen. If you can execute this command... Good luck. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

      1 Reply Last reply
      0
      • C CreepingFeature

        :sigh: I am just starting with C++, and have a problem. I wrote a text game but the thing is some times I want the new question etc to start at the top of a clean black screen (that is erase all previous lines). I could just put a pile of endl; but a couple of days ago somewhere on the site I saw a clrScrn; statment or something like that and remembered BASIC. Could someone tell me the the #include and the correct way to use it. Thanks in advance!

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        Here is you solution If you working in Text mode see cls() function it is defined in if you working in Graphis mode see function cleardevice() ,it is defiend in graphics.h ----------------------------- "I Think It will Work" Formerly Known As "Alok The Programmer" at CP ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

        1 Reply Last reply
        0
        • C CreepingFeature

          :sigh: I am just starting with C++, and have a problem. I wrote a text game but the thing is some times I want the new question etc to start at the top of a clean black screen (that is erase all previous lines). I could just put a pile of endl; but a couple of days ago somewhere on the site I saw a clrScrn; statment or something like that and remembered BASIC. Could someone tell me the the #include and the correct way to use it. Thanks in advance!

          A Offline
          A Offline
          avenger_sb25
          wrote on last edited by
          #4

          >>erase all previous lines). For dos baserd compiler... the function is: clrscr(); The header file for it is #include conio=Console I/O I hope that makes you happy. :) ...Avenger


          Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs

          1 Reply Last reply
          0
          • C CreepingFeature

            :sigh: I am just starting with C++, and have a problem. I wrote a text game but the thing is some times I want the new question etc to start at the top of a clean black screen (that is erase all previous lines). I could just put a pile of endl; but a couple of days ago somewhere on the site I saw a clrScrn; statment or something like that and remembered BASIC. Could someone tell me the the #include and the correct way to use it. Thanks in advance!

            A Offline
            A Offline
            Archer282
            wrote on last edited by
            #5

            im assuming you have Visual C++, unfortunatly VC++ doesnt come with the old functions like gotoxy() or clrscrn() that Dev-C++ offers here is a ClearScreen() function i wrote along time ago (with SetXY() function) void SetXY(int X, int Y){ COORD dwCoord; dwCoord.X = X; dwCoord.Y = Y; SetConsoleCursorPosition(STDHANDLE,dwCoord); } void ClearScreen(){ COORD dwCoord; DWORD nLength; DWORD lpResult; CONSOLE_SCREEN_BUFFER_INFO Info; GetConsoleScreenBufferInfo(STDHANDLE, &Info); dwCoord.X = 0; dwCoord.Y = 0; nLength = Info.dwSize.X * Info.dwSize.Y; FillConsoleOutputCharacter(STDHANDLE, ' ', nLength, dwCoord, &lpResult); SetXY(0,0); } ohh i almost forgot #define STDHANDLE GetStdHandle(STD_OUTPUT_HANDLE)

            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