Hi guys, I'm just starting out and I'm having a little problem. When I run an application, it closes by itself right away.
A few days ago I went to the Local Library and picked out "Sam's Teach Yourself C++ in 24hrs - I know it's a lie" It came with a CD so that you can install Borland C++ - don't know what version it is, though it looks from at the least 2000. I had some trouble installing it and the interface looked pretty lame (old) so after searching through the forums I downloaded Dev-C++.
And I'm having the problem that the #4 poster had.
http://www.daniweb.com/forums/thread19944.html
I copied and pasted what poster #5 did and it worked. However when I tried to compile it without the C-style comments, I couldn't get it to work.
But the main problem I'm having is that when I run an app. It closes immediately. It's happened with two other tutorials in the book that I tried. I've come the conclusion that I'm doing them right since they open, I just can't get it to remain open for more than a second.
Here are the two other tutorials that I tried. Again they compiled without errors, and the app. ran except it closes down instantaneously. Thanks
callfunc.cpp
#include <iostream>
void DemonstrationFunction()
{
std::cout << "In Demonstration Function\n";
}
int main()
{
std::cout << "In main\n" ;
DemonstrationFunction();
std::cout << "Back in main\n";
return 0;
}
func.cpp
#include <iostream>
int Add (int x, int y)
{
std::cout << "In Add(), received " << x << " and " << y << "\n";
return (x+y);
}
int main()
{
std::cout << "I'm in main()!\n";
std::cout << "\nCalling Add()\n";
std::cout << "The value returned is: " << Add (3,4);
std::cout << "\nBlack in main().\n";
std::cout << "\nExiting...\n\n";
return 0;
}