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. Other Discussions
  3. Article Writing
  4. clrscr() and gotoxy() in Visual C++

clrscr() and gotoxy() in Visual C++

Scheduled Pinned Locked Moved Article Writing
c++question
2 Posts 2 Posters 2 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.
  • E Offline
    E Offline
    Ernesto Moscoso Cam
    wrote on last edited by
    #1

    It is well known that the common functions clrscr() and gotoxy() are not supported in Visual C++. But I presume that calling directly to DOS interruptions using in-line assembler would provide a convenient way of making this functions. Since I don't know Assembler programming, does anybody have these two function already made?

    T 1 Reply Last reply
    0
    • E Ernesto Moscoso Cam

      It is well known that the common functions clrscr() and gotoxy() are not supported in Visual C++. But I presume that calling directly to DOS interruptions using in-line assembler would provide a convenient way of making this functions. Since I don't know Assembler programming, does anybody have these two function already made?

      T Offline
      T Offline
      Tim Deveaux
      wrote on last edited by
      #2

      I think you'll bugcheck on 98 with an _asm int 21; Here's some code that might help: The clrscr can be had with system("cls"); The more powerful way us to get a handle to the console and use the console api calls. The MS Knowledge base has a good article on clearing the screen - Q99261 - first, you need a handle though...

      // with this handle, article Q99261
      HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

      // call a console API just to test handle
      CONSOLE_SCREEN_BUFFER_INFO csbi; // just to test

      // wow! hConsole is NULL! But this works! Go figure...
      GetConsoleScreenBufferInfo(hConsole, &csbi);

      // now we can gotoxy with SetConsoleCursorPosition
      COORD coord;
      coord.X = 0;
      coord.Y = 0;

      SetConsoleCursorPosition(hConsole, coord);

      That should move the cursor to the top of the screen without clearing it. See Q99261 for the clear screen.

      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