display int result (newbie)

This is a discussion on display int result (newbie) within the C++ Programming forums, part of the General Programming Boards category; i did a tutorial on gallons to litres converstion, my trouble is that when i hit the enter key after ...

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

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.

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.