Hi
I just finished another section on my C++ book which went over functions. I understood it completely and all--or inleast I thought I did. To practice what I just learned I wrote a simple program with two functions, myMessage() and of course main(). main() passes control to myMessage() which in turn displays a message and passes control back to main(). Now, the problem I came across was in pausing the program so I can view the results. No matter where I put the system("pause") or even getch(); functions the program would pause at the beginning.
I know there must be some simple mistake as I've been making a lot of those lately. Can someone please enlighten me of a way around this problem?Code:#include <iostream.h>
#include <stdlib.h>
// define function that will display message
void myMessage()
{
cout << "Message from myMessage() here";
return;
}
void main()
{
cout << "Message from main() here\n\n";
myMessage();
system("pause");
return;
}