Thread: can anyone help about this?

  1. #1
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85

    can anyone help about this?

    hi guys, first of all i would like to say a "Hi" to all of u here since i'm new here, just registered here

    yeah, my question is this:

    i'm used to using the Borland Turbo C++ compiler. Now i have decided to switch to Visual C++.
    But in Turbo i was used to inlcuding the library <conio.h> which allowed me to use functions like clrscr(); and getch();
    BUT with the visual i saw that it's not possible..so how to use conio.h with the 2functions i usually use or is there any alternatives in visual???
    Thanks for your time and attention.

    Kind Regards!

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    in msvc getch is _getch(). clrscr you can write yourself same as gotoxy. details in the FAQ.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    hey tnx for your response dude! :tup:
    Last edited by wakish; 09-20-2005 at 05:09 PM.

  4. #4
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    for the clrscr(), is it this function:

    Code:
    #include <curses.h> 
    
    void clrscr(void)
    {
        static int init;
    
        if (init == 0)
        {
            initscr();
            init = 1;
        }
    
        clear();
        refresh();
    }
    how should i include this function in the library of the Visual C++ compiler?
    sry, but i'm still in learning phase...
    tnx!

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    find the include folder in the microsoft visual studio folder then add it in there

    then #include "NAME.h"
    hooch

  6. #6
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    Quote Originally Posted by ssjnamek
    then #include "NAME.h"
    am i getting it right:

    1- i save the code as clearscreen.h in the include folder of the visual compiler
    2- i include #include<clearscreen.h> in my source codes which i will be writing.

  7. #7
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    add the it in quotes "NAME.h" for microsoft's compiler. i think thats standard but ive heard it varies. it seems to think if its not standard already then it needs quotes at least this is my knowledge.
    hooch

  8. #8
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    ok..i'll try that..stay tuned...tnx dude!

  9. #9
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    theres also a cls though not sure how effecient it is as its directly to dos but am curious how effecient it is to use this vs something else?

    #include <stdlib.h>//<cstdlib>

    system("cls"); //enter dos commands
    hooch

  10. #10
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    hey the above code i found in the faq does not work..and the _getch() also does not work properly...
    ok, i'm re-stating what i want:
    when i used to code with Borland Turbo C++, i used to put the functions clrscr(); and getch(); at beginning and end, respectively. This was useful in the sense that when i click on the created .exe file, i could see the output...but without getch(); when i open the .exe file, the window just opens and closes in a fraction of a second, without allowing to see the output!
    So any remedy to this those who are comfortable with Visual C++ ???

  11. #11
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    when i open the .exe file, the window just opens and closes in a fraction of a second, without allowing to see the output!
    So any remedy to this those who are comfortable with Visual C++ ???
    You can either use:
    Code:
    cin.get();
    right before the return 0 (or whatever).

    Or you can use:
    Code:
    system("pause");
    Though the first one is prob best to use, but requires the enter key to be pressed. The other, any key will then exit.

  12. #12
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    no dude, none of them work...infact when i click on the .exe there is no ouput, but it waits for me to click "any key...", then it deappears without having time to see the output.

  13. #13
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    They work.
    You want to put right before the return 0 of your main function. Not before anything goes.
    Code:
    int main()
    
    {
    cout << "Compile this, it works." << endl;
    
    
    
    system("pause");
    	 
      return 0;
    }
    
    OR
    
    int main()
    
    {
    cout << "Compile this, it works." << endl;
    
    
    cin.get();
    	 
      return 0;
    }

  14. #14
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    hey dude i appreciate your effort..tnx!

    but these functions does not really do what a getch(); normally does with Borland Turbo C++

    i get these:

    1) when using the cin.get();

    the output appears on the screen, then the cursor is on next line...waiting for me to type any key...Then when i press any key, the sentence "press any key to continue..." appears
    I want this sentence to appear after the output directly..this is more sound!

    2) with system("pause");

    the sentence "press any key to continue ..." appears FIRST and when i press any key, the window closes instantly without me seeing the output

  15. #15
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Just do this:

    Code:
    #include <iostream>
    using namespace std;
    
    int main(void){
        //All your program's calls and stuff here
        cout << "Press ENTER to exit. ";
        cin.get();   //or....
        //getchar();
        return 0;
    }

Popular pages Recent additions subscribe to a feed