Automatic Closing
I need help with a problem that occurs when I try and make C++ applications. When I try to run any application in C++ it automatically closes within a split second. Even a simple 'Hello World' program will do that. To make it stop I always have to put in this statement:
markupstd::cin.ignore(std::cin.rdbuf()->in_avail() + 2);
Is there any way to make it so where I don't have to put in that statement? Don't flame please I just want to figure out why this is happening :|
Thanks, Kirk
It is console. And sorry, I don't get what you mean by pause. But this is just an example. Even THIS closes automatically:
#include <iostream>
using namespace std;
int main()
{
cout<<"This is stupid because this closes automatically!";
return(0);
}
But when I put markupstd::cin.ignore(std::cin.rdbuf()->in_avail() + 2);
it works fine and all I have to do is hit enter twice depending on how many times I have input in the program
kirk_halo1994 wrote: It is console. And sorry, I don't get what you mean by pause. But this is just an example. Even THIS closes automatically:
#include <iostream>
using namespace std;
int main()
{
std::cout<<"This is stupid because this closes automatically!";
return(0);
}
system("pause"); Alright, this is how i would've wrote that:
#include <iostream.h>
using namespace std;
int main()
{
cout << "This is stupid because this closes automatically!";
system("pause");
return 0;
}
I'll try that out real quick hold on. Thanks for the help. :)
EDIT: It works but I have 3 books on C++, Practical C++ Programming 2nd Edition, C++ without fear, and C++ the core language but they all don't show that. But thanks a lot. You helped me out a ton because I hate trying to remember that statement :P
kirk_halo1994 wrote: I'll try that out real quick hold on. Thanks for the help. :)
EDIT: It works but I have 3 books on C++, Practical C++ Programming 2nd Edition, C++ without fear, and C++ the core language but they all don't show that. But thanks a lot. You helped me out a ton because I hate trying to remember that statement :P
hehe youve been to Cprogramming.net haven't you? I got those exact same books, what did you think of them?