My compiler won't pause on getchar();. I have Dev C++ and if I put getchar(); at the end of the program, it doesn't stop, and the console window still exits. It still exits when I assign a variable to it
c = getchar();
Is there another way to pause the program with C, without using system("PAUSE");
Firestone 0 Light Poster
Recommended Answers
Jump to Post— Ancient Dragon 5,243The program will not stop if there are still keystroks in the keyboard buffer, such as if you previously called scanf() to get an integer the '\n' will still be in the keyboard buffer. But you will have to post your program for anyone to give you more help with …
Jump to Post— Narue 5,707>Is there another way to pause the program with C, without using system("PAUSE");
Sure. Don't run your program in an IDE that isn't smart enough to keep the window open. Run it from the command prompt.
Jump to Post— Member #46692The problem arises when you are using different variables to read stuff, like ints and strings.
My advice would be to read everything in as a string and just convert to ints or floats where necessary.
All 12 Replies
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Narue 5,707 Bad Cop Team Colleague
Member #46692
Narue 5,707 Bad Cop Team Colleague
Member #46692
Firestone 0 Light Poster
Narue 5,707 Bad Cop Team Colleague
Member #46692
Firestone 0 Light Poster
Member #46692
ayarosh 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.