Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.
Moderator: Moderators
-
lena2383
- Posts: 3
- Joined: 2003-05-30 02:39
Post
by lena2383 » 2003-05-30 02:43
Hi guys I am new to the C++ programming but I am learning it, some of it anyway. Problem when I excute my program it will automatically return back to the coding. I don't get to see my results. WHY
I thank you in advance
JB

-
sleepy
- Posts: 1
- Joined: 2003-05-17 01:55
Post
by sleepy » 2003-05-30 03:37
I think this will do it for you. You'll need to see which include has PAUSE in it.
int main()
{
... put this right after your results are displayed
system("PAUSE");
... press a key to continue (back to your code)
}
-
TheParanoidOne
- Forum Moderator
- Posts: 1420
- Joined: 2003-04-22 19:37
Post
by TheParanoidOne » 2003-05-30 08:04
Or compile it in your IDE but run it from a command line.
-
lena2383
- Posts: 3
- Joined: 2003-05-30 02:39
Post
by lena2383 » 2003-05-30 16:01
here is my code and were I put the system Pause
//T3AppE02.cpp - calculates and displays the new weekly pay
#include <iostream>
using namespace std;
int main()
{
//declare variables
float currentPay = 0.0;
float rate = 0.0;
float raise = 0.0;
float newPay = 0.0;
//enter input items
cout << "Enter current weekly pay: ";
cin >> currentPay;
cout << "Enter raise rate: ";
cin >> rate;
//calculate raise and new pay
raise = currentPay * rate;
newPay = raise + currentPay;
//display output item
cout << "New pay: " << newPay << endl;
sysrem ("Pause");
return 0;
} //end of main function
-
Gratch06
- Posts: 141
- Joined: 2003-05-25 06:48
- Location: USA
Post
by Gratch06 » 2003-05-30 18:05
You need to include the cstdlib file at the top
#include <cstdlib>
C++ is case sensitive. The command needs to be:
system("PAUSE");
- Gratch
-
lena2383
- Posts: 3
- Joined: 2003-05-30 02:39
Post
by lena2383 » 2003-05-30 19:14
Thanks to you all for you input it working correctly and I thanks you again
JB

-
arnetheduck
- The Creator Himself
- Posts: 296
- Joined: 2003-01-02 22:15
Post
by arnetheduck » 2003-05-31 00:43
That's not a very good way because it's system dependant. Better not to move outside C++, and do something like
Code: Select all
cout << "Press any key";
cin.get();
Then you don't need to include cstdlib either. system is a legacy function from the old times of C...
Users browsing this forum: Google [Bot] and 0 guests