1

What is the system("pause") equivalent in Linux on C language. not C++.

I want to use that for my c program. Theres a logout function. But before it returns to the main login function i want to give user a message that he is successfully logged out.

my function is

void logout() {
    printf("You are successfully logged out\n");
    system("pause");
    login();
}
5

You can use getchar to achieve that:

#include <stdio.h>

void logout() {
    printf("You are successfully logged out\n");
    int c = getchar();
    login();
}
  • Thanks. That helps a lot. Sorry, I cant up vote because I'm new here. – Shaman Sharif Nov 27 '17 at 18:11
  • 2
    @ShamanSharif If this answer solved your issue, please take a moment and accept it by clicking on the check mark to the left. That will mark the question as answered and is the way thanks are expressed on the Stack Exchange sites. – Videonauth Nov 27 '17 at 22:25
  • Has the int c = allocation any reason to be there? (not a C coder, just curious) – Aaron Nov 27 '17 at 22:50
  • @Aaron Not really, but it just makes it clear that the function returns something. – SurvivalMachine Nov 28 '17 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.