c++ Pause Command for Linux Terminal

Hi

I want to pause my program in Linux Terminal. But i can't.

i Have tried many commands, Like
system("pause");
sleep(100);
usleep(10);
getchar();
cin.get();

No one is working on linux terminal.
Please help me.

Thnx in advance
Last edited on
cout<<"Press ENTER to exit";
cin.ignore(cin.rdbuf()->in_avail()+1);

But srsly, either start the program from the console, or start it from the IDE. A program that asks for user input before termination is not very user friendly (ex: You could direct cout and cin to files - in that case, it would be very stupid to ask for further user input)
You can use "read" but this should only be a temporary solution.
Hanst this code is not working
cout<<"Press ENTER to exit";
cin.ignore(cin.rdbuf()->in_avail()+1);


and i am not able to use the "read" command please specify the command.
That code works perfectly fine for me. Anyways, what you should really do is just ignore the pause part and launch the program from the terminal. Terminal applications are expected to be run from the terminal.
ya i am able to run the program. but i want to pause the program at the end of the program.

but i can't pause................... anyone can tell me.
i did it by this command.
You can also try .
Thnx for help

Pause Command

#include <iostream>
using namespace std;

int main()
{
cout << "Enter to exit the program: ";

cin.ignore().get(); //Pause Command for Linux Terminal

return 0;
}
The "command" depends entirely on linux terminal type, there are many of them and no standard ones like windows built-in cmd.exe when everybody know what to do.
The question is, WHY do you WANT to pause? it doesn't even make any sense to do that.
i just want to know the command.
nothing more.........

now i can pause in Ubuntu terminal...... ;)
Topic archived. No new replies allowed.