Thread: conio.h for Visual C++

  1. #1
    Registered User Doc.'s Avatar
    Join Date
    Dec 2008
    Location
    Jamaica
    Posts
    24

    conio.h for Visual C++

    how do i use gotoxy and clrscr in visual c++;

    i tried this as an alternative
    Code:
    #include <windows.h>
    
    int main(void)
    
    {
    HANDLE console_handle;
    COORD cursor_coord;
    char *buffer ="Hello World\n";
    DWORD actual=0;
    
    cursor_coord.X=(40-(strlen(buffer)/2)); //In VC++ 6.0 you have to write
    x and y in caps or you'll get and error.
    cursor_coord.Y=10;
    
    console_handle= GetStdHandle( STD_OUTPUT_HANDLE);
    
    if (SetConsoleCursorPosition(console_handle,cursor_coord)) //This would
    be the equivalent to gotoxy(x,y).
    
    WriteConsole(console_handle,buffer,strlen(buffer),&actual,NULL);// Look
    up this function in your VC++ help/index
    
    return 0;
    }
    but it doesnt come with windows.h either

    any help would be gladly appreciated

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Quote Originally Posted by Doc. View Post
    Code:
    cursor_coord.X=(40-(strlen(buffer)/2)); //In VC++ 6.0 you have to write
    x and y in caps or you'll get and error.
    Probably because the field's name is in upper-case, rather than lower-case; programming (in general) is case-sensitive.

    Quote Originally Posted by Doc. View Post
    but it doesnt come with windows.h either
    What doesnt come with "windows.h"? This is a big chunk of code, and its possible everything does exist in the header file, except for just one.

    Did you read the FAQ? Cprogramming.com FAQ > gotoxy() in a Windows Console I didnt look into any "clrscr" stuff, but I guess you could start with this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. conio.h not working in *nix
    By wise_ron in forum C Programming
    Replies: 2
    Last Post: 05-04-2006, 01:54 PM
  2. conio.h and the gotoxy(int, int) function
    By nextus in forum C++ Programming
    Replies: 3
    Last Post: 11-29-2002, 03:47 PM
  3. conio.h
    By Jaguar in forum Linux Programming
    Replies: 10
    Last Post: 10-17-2002, 01:12 AM
  4. Conio.h file problems
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 05-23-2002, 01:44 PM
  5. conio.h
    By doh! in forum C++ Programming
    Replies: 1
    Last Post: 04-02-2002, 10:07 AM