C++ number finder

I just started to learn C++. I am using dev compiler etc.

I made a average number finder that finds the average of three numbers. When I open it says "Please enter three numbers." How can I make it so it says "Welcome to blah blah's average number finder" etc or whatever then it shows that press any key to continue message then you hit enter or whatever key and it goes onto the page where it says, "Please enter three numbers"

thanks
You could use system("pause") on windows, but system is evil and bad practice.

The best way to do it is to print the text with cout or printf, and then use std::cin.get(); or std::cin.ignore();
Refer to the sticky at the top of the beginners forum ('console closing down') and the article 'why system is evil' in the articles section.
 
std::cin.ignore(std::cin.rdbuf()->in_avail(), std::cin.get());
In other words, how do you make the program pause until the user presses some key right?

This article sums it up just fine. It really makes no difference where in your program you need to put the pause.
http://www.cplusplus.com/forum/articles/7312/

I recommend this approach. Of course you don't have to make it an entire function. You just need those two lines of code within the body and the two header inclusions at the top. I'm sure you must already know how to print the additional messages so this is really the critical part that you are asking about.
1
2
3
4
5
6
7
8
#include <iostream>
#include <limits>

void PressEnterToContinue()
  {
  std::cout << "Press ENTER to continue... " << flush;
  std::cin.ignore( std::numeric_limits <std::streamsize> ::max(), '\n' );
  }
Topic archived. No new replies allowed.