Thread: gotoxy function

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    4

    gotoxy function

    IN my program i have

    gotoxy(1,a);
    putch('1');



    where a is a value. I have

    conio.h
    stdlib.h
    stdio.h
    iostream.h
    dos.h

    included and it says that gotoxy is an undeclared identifier.

    I have no idea why. Im kind of a newbie and this is my first game.

    Thanks for your help

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    gotoxy() is compiler specific, implemented by some, not others, i.e. not a standard function. It could be that you are using a compiler which does not support it.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    4
    I have MSVC++6 and just tried DEV. and both dont work. I need this program. If someone could compile it for me and send me back the exe i would be greatfull

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Code:
    #include <iostream.h>
    #include <windows.h>
    
    HANDLE hStdOut;//need handle to console output
    
    void clrscr()
    {
       COORD coordScreen = { 0, 0 };
       DWORD cCharsWritten;
       CONSOLE_SCREEN_BUFFER_INFO csbi;
       DWORD dwConSize;
    
       GetConsoleScreenBufferInfo(hStdOut, &csbi);
       dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
       FillConsoleOutputCharacter(hStdOut, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
       GetConsoleScreenBufferInfo(hStdOut, &csbi);
       FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
       SetConsoleCursorPosition(hStdOut, coordScreen);
    }
    
    void gotoxy(int x, int y)
    {
       COORD coord;
       coord.X = x;
       coord.Y = y;
       SetConsoleCursorPosition(hStdOut, coord);
    }
    
    int main(){
    
    hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); //Grab console out stream
    
    clrscr(); //clear console
    
    for(int x = 0;x<10;x++){
    gotoxy(x+10,x+1);
    cout << "Hello World" << endl;
    }
    return 0;
    }
    I dont have time to go through your code, but here is a quick example of how you can implement functions like clrscr() & gotoxy() in M$VC++....

    They are not difficult....its just that you must recreate the functions yourself cuz M$ dont provide a library with them in.

    How I manageged to recreate this code so quickly is because this stuff is listed in the "programmer's Faqs" for this site.....have a look before you post next time.


    P.S. I know this is the C Board and I have used C++....I forgot where I was

  5. #5
    Registered User breed's Avatar
    Join Date
    Oct 2001
    Posts
    91
    I had to alter the bool running = true
    bool_running

    and #defined true 1
    #define nottrue 0

    but it runs and the exe is attached

    i used turboC++
    Before you judge a man, walk a mile in his
    shoes. After that, who cares.. He's a mile away and you've got
    his shoes.
    ************William Connoly

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Post your games here...
    By Hammer in forum Game Programming
    Replies: 132
    Last Post: 02-28-2013, 09:29 AM
  2. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  3. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  4. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM