Thread: display int result (newbie)

  1. #1
    Unregistered
    Guest

    display int result (newbie)

    i did a tutorial on gallons to litres converstion, my trouble is that when i hit the enter key after typing in the interger the console window closes and i dont see the conversion variable result. I have included the line " cin.get() before return 0 to force the console window to stay open . Not sure what to do

  2. #2
    Still A Registered User DISGUISED's Avatar
    Join Date
    Aug 2001
    Posts
    499
    hmmm, I am not really sure why cin.get() wouldn't work. You could try getchar(); or because it's a simple program you could #include<windows.h> and then use system("pause"); but that's really not the best way.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    99
    I think you mean "#include <stdlib.h>"
    or do they both work?

  4. #4
    looking for the truth moemen ahmed's Avatar
    Join Date
    Feb 2002
    Location
    Egypt
    Posts
    161
    simply u can use getchar or u can use
    [code]
    #include <iostream.h>

    int main(){
    //..... your stuff


    ch a;
    cin>>ai>> endl;
    return ();
    }
    Programming is a high logical enjoyable art for both programer and user !!

  5. #5
    Still A Registered User DISGUISED's Avatar
    Join Date
    Aug 2001
    Posts
    499
    Originally posted by Da-Spit
    I think you mean "#include <stdlib.h>"
    or do they both work?
    Ya know, I have never really used that function. I know that it works and yeah it's windows.h but I have been told it's not a good idea. I guess it's in stdlib as well? but like I said I don't use it so I wouldn't know.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 03-10-2008, 11:57 AM
  2. Drawing Program
    By Max_Payne in forum C++ Programming
    Replies: 21
    Last Post: 12-21-2007, 05:34 PM
  3. Converted from Dev-C++ 4 to Dev-C++ 5
    By Wraithan in forum C++ Programming
    Replies: 8
    Last Post: 12-03-2005, 07:45 AM
  4. Switch/case Problems (long code in post)
    By Wraithan in forum C++ Programming
    Replies: 2
    Last Post: 12-01-2005, 06:40 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM