can anyone help about this?

This is a discussion on can anyone help about this? within the C++ Programming forums, part of the General Programming Boards category; uuummm...yeah it surely works, but it's not the proper way though But tnx for your time and attention dude!...

  1. #16
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    uuummm...yeah it surely works, but it's not the proper way though

    But tnx for your time and attention dude!

  2. #17
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Care to show us your code?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #18
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    hey if u have read my questions in page 1 you will notice that my question is independent of what code u write!

  4. #19
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    i still have not find the solution

  5. #20
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    The proper solution depends on your code.

  6. #21
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    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++ ???




    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


    So i dn't see y u r asking me for codes since it's not code dependent at all...it's general....

  7. #22
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    What about _getch() recommended in the first response? I assumed you tried that.

    Your description of what happens with cin.get() doesn't make sense based on the rest of what you've said. Your code would help clarify what is wrong.

    The problem with system("pause") is probably due to your code. If you aren't flushing your output correctly, then it won't be shown before the "press any key to continue ..." part.

    You must have some code to test these suggestions with. If the suggestions aren't working the way you want them to, show how you are trying to implement them and we can tell you what is wrong more easily.

  8. #23
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    dude i assure u that i have described what i'm getting when using the cin.get()
    yeah i have tried _getch() too, same result..
    and for the code, i'm just trying to do what i want, so i'm trying all these using only this simple code:

    Code:
    #include <iostream.h>
    #include <conio.h>   //for the _getch() relating functions
    #include <stdlib.h>  //for the function system("pause")
    
    void main()
    {
        cout << "\nHi! This is a test line!" << endl;
    
       _getch();
       // or the other functions like cin.get() , system("pause")...i place them here dude.
    
    }//end main

  9. #24
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    A few things about your current code:

    a) It's <iostream>. Not <iostream.h>.
    b) <cstdlib>, not <stdlib.h>
    c) int main(). void main() will get you killed in these parts.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  10. #25
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    btw is there any functions to clearscreen in visual C++ dude??

    i tried one(view post on 1st page here), but does it can't find <curses.h> (i saw this in FAQ)
    Last edited by wakish; 09-22-2005 at 08:33 AM.

  11. #26
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    hey Daved if u pass by again, these 2last post was addressed to u...so plz if u cud continue on ur analysis..tnx dude!
    Last edited by wakish; 09-22-2005 at 08:31 AM.

  12. #27
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Mmm.... FAQ goodness.

    As for clearing the screen, we've got that in the FAQ as well.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  13. #28
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    That code helps a lot. When I run that in Visual Studio 7.1 it doesn't compile because of the reasons mentioned by XSquared. It does compile in VC++ 6.0, so I assume that's what you are using.

    When I run the program through the debugger with F5, it works just as I would expect you'd want it to. It prints the Hi message, then I hit a key and the window disapeears. When I execute the program without the debugger with Ctrl-F5, It also does this. However, after I hit a key the window doesn't disappear, instead the "press any key to continue" message appears and I have to hit another key.

    That happens because Visual Studio adds the equivalent of _getch() to the end of your console program when you execute it. In other words, if you use Execute (Ctrl-F5) to test your program, you don't even need the the _getch(). However, try going through Windows explorer and finding your executable in the Debug directory of your project. Double-click on it. This time it probably works as you want it to, because you didn't run it through the IDE and so the _getch() that you put in yourself did it's job.

    If things aren't working for you the way I described them, then I don't know what the problem is. As for clearing the screen, I've never done that myself, but you might want to try all the options available in that FAQ. I'm sure a couple of them will work.

  14. #29
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    ....Stop saying 'dude' so much.

    Code:
    #include <iostream>
    using namespace std;
    
    int main(void){
        cout << "This will display just fine. Now press ENTER to exit." << endl;
        cin.get();
        return 0;
    }
    That's all there is to it. If that doesn't work...you must have something screwed up on your compiler or something lad.

  15. #30
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    didn't the term "dude" go out in the 70's? I didn't think anyone used it any more.

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21