Thread: Print without flashing cursor

  1. #1
    Registered User johnnyd's Avatar
    Join Date
    Mar 2002
    Posts
    70

    Lightbulb Print without flashing cursor

    Hey, quick question, do any of you fellas know how to print a line of text to the screen without that tacky flashing cursor being there every single time?

    I only want the cursor to be visible when the user is doing data entry. Thanks in advance.
    Excuse me, while I water my money tree.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    This is a nonstandard feature, here's the way to do it in Windows:
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    int main ( void )
    {
      CONSOLE_CURSOR_INFO c;
      c.dwSize   = 1;
      c.bVisible = 0;
      SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &c );
    
      printf ( "This is a program with no cursor\nHit any key to proceed\n" );
      getchar();
      return 0;
    }
    When you want the cursor to be visible, simply change bVisible to 1 or some variation of true and call SetConsoleCursorInfo again.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Patent Pending GSLR's Avatar
    Join Date
    Sep 2001
    Posts
    134

    Cool Reply

    Hi ,

    You can also use the conio.c header file , just read through it , you should get the I D A .

    Cheers

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >You can also use the conio.c header file
    Can you guarantee that conio will have what is needed for any compiler on a given operating system? If you said yes, you're wrong. Borland has an extensive conio file, but just about every other compiler won't have those features and the program will break. At least using the Windows API you can be sure it will work on all Win32 compilers. In the case of nonstandard features, you pick the option that is the most portable.

    -Prelude
    My best code is written with the delete key.

  5. #5
    Registered User johnnyd's Avatar
    Join Date
    Mar 2002
    Posts
    70

    Talking It WORKS!!

    Prelude, YOU THE MAN!!

    Dude, you are THE bomb. U R 2 cool 2 B real...
    Excuse me, while I water my money tree.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. merging linked lists
    By scwizzo in forum C++ Programming
    Replies: 15
    Last Post: 09-14-2008, 05:07 PM
  2. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  3. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  4. What kind of programs should I start writing?
    By Macabre in forum C++ Programming
    Replies: 23
    Last Post: 04-12-2003, 08:13 PM
  5. Mouse in 800x600 24Bit Mode?
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 11-11-2001, 01:38 AM