Thread: getch() problem with Dev C++

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    59

    getch() problem with Dev C++

    Has anyone ever had a problem using getch() with dev c++ compiler?

    If so how do i fix it?

    or is this function only standard with Borland?


    Cheers guys

    Boontune

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    You are Dead Right!!!

    Originally posted by boontune
    Has anyone ever had a problem using getch() with dev c++ compiler?

    If so how do i fix it?

    or is this function only standard with Borland?


    Cheers guys

    Boontune
    getch() is a non-standard function and its generally present in the headerfile <conio.h> // console input output headerfile

    why don't you create a dummy variable and use a cin
    Code:
    char dummy;
    cin >> dummy; // ofcourse it will wait till you press enter key
    cin.ignore(); // to flush the '\n' (enterkey) if still in the stream
    Have a wonderful day.... and keep smiling... you look terrific that way
    signing off...
    shiv... as i know him

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    Why no use cin.get() (no params) to wait for the enter key?

    -Futura
    If you speak or are learning Spanish, check out this Spanish and English Dictionary, it is a handy online resource.
    What happens is not as important as how you react to what happens. -Thaddeus Golas

  4. #4
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953

    Re: getch() problem with Dev C++

    Originally posted by boontune
    Has anyone ever had a problem using getch() with dev c++ compiler?

    If so how do i fix it?

    or is this function only standard with Borland?


    Cheers guys

    Boontune
    What is the problem you are having?! I didn't have one but I hope I can help you.
    none...

  5. #5
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Code:
    cout << "Press any key to continue....";
    char wait = getch();
    
    // or 
    
    cout << "Press any key to continue....";
    cin.get();
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  6. #6
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    It looks as if getch() isn't in conio.h, but I got this to work with a bit of effort

    Dev C++ ver 4.?

    Code:
    #include <iostream>
    #include "C:\Dev-C++\Include\conio.h"
    
    using namespace std;
    
    int main(void)
    {
       char letter;
       letter = getche();
    
       return 0;
    }
    Look in the conio.c and conio.h files for seeing what code is finished. It looks like some of the functs aren't et done.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

  7. #7
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    Try including conio_mingw.h instead of conio.h

    -Futura
    If you speak or are learning Spanish, check out this Spanish and English Dictionary, it is a handy online resource.
    What happens is not as important as how you react to what happens. -Thaddeus Golas

  8. #8
    Registered User
    Join Date
    Oct 2002
    Posts
    59
    Thanks alot for your help guys!

    Il give it ago and let you know how i got on.

    Cheers

    Boontune

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. Problem with getch() and fgetc()
    By Krupux in forum C Programming
    Replies: 3
    Last Post: 10-01-2002, 11:38 PM
  4. Dev C++ problem
    By Bluehead in forum Windows Programming
    Replies: 1
    Last Post: 08-21-2002, 05:33 PM
  5. Problems with getch()
    By GrNxxDaY in forum C++ Programming
    Replies: 14
    Last Post: 08-12-2002, 02:11 AM