is it?what really happens if you dont put system("PAUSE")?i heard that if you enter it,then you wont be able to print the output and all...
Printable View
is it?what really happens if you dont put system("PAUSE")?i heard that if you enter it,then you wont be able to print the output and all...
It is not required at all.
- There are (more or less) substitutes for it, some of which are more portable as well.
- You can just run your program via the command line/prompt, as you should do in the first place.
- The need for it disappears if your program is not even meant to be run from the command line/prompt.
oh thanks!Actually i am new to C++ programming.i am a student,and we have a test tomorrow.The examiner cuts marks if you dont put in system("PAUSE")
Well, if the examiner insists, then go ahead and do so, but note that the examiner is misguided.
thanks.Also,what is the difference between the post-increment and pre-increment operator?We were told its the same thing but i have a doubt.....
int n = 10;
int x = n++;
cout << x; // Prints 10
cout << n; // Prints 11
x = ++n;
cout << x; // Prints 12
cout << n; // Prints 12
That should answer your question.
A quick search of the Web reveals Difference between pre-increment and post-increment.Quote:
Also,what is the difference between the post-increment and pre-increment operator?
In that case I must advise you that your teachers are not just misguided, but terribly ignorant, possibly even incompetent. If this is a private course, you would be better off dropping it.Quote:
We were told its the same thing but i have a doubt.....
its a subject in school.And the teacher comes for half an hour one day before the exam and completes the course.If it isnt completed,then its self study.Thats the case this time,so that is exactly why im sitting online surfing tutorials.
In English, post-increment makes a copy of the object with the old value, does the operation, and returns the copy. Pre-increment simply does the operation and returns a reference to the object. So it depends entirely on whether you need the initial value, most of the time. If copying the object is a performance bottleneck, than you know what to avoid...
oh.
what are logical operators?
We actually have a tutorial section on this site. It is not much, some of it is outdated, but at least it is something. In particular, check out the tutorial on if statements. At the bottom it has something to say about the logical operators (or what it calls boolean operators).
Oh wait it does. LOLtomyself
I bet what the examiner is actually requring is that there are pauses in the execution of your code, more so than actually using system("PAUSE"). I betcha I can hack into your computer if you keep using that, and I am not turning to the dark side on anyone here... I am simply pointing out that your programs have an easily exploited security breach in them. Several times per execution, in fact.
No, they don't. You can make them do unexpected things, but you cannot breach security. You cannot use them to gain permissions you don't already have. (You might, under very special circumstances, be able to trick someone into executing your code.)
system("pause"); causes my win '98 laptop pain!
Really, it overheats if I leave it for a few minutes.
That indicates to me that it's asking the cpu to do an endless loop or something. (way to go Bill guys...)
I just use a blocking function loop like while(getchar() != '\n'); in C or while(cin.get() != '\n'); in C++.
And re: pre- and post-increment / decrement :
Code:cout << endl << "Hit enter to continue";
while(cin.get() != '\n');
int x = 10;
cout << x++ << endl; // prints 10 increments after usage so...
cout << x << endl; // prints 11 the change shows up next time x is used
cout << --x << endl; // prints 10 decrements before usage so shows up immediately
cout << x-- << endl; // prints 10 after...
cout << x << endl; // prints 9 get the idea?
Yes, Really. Running this alone causes fan to come on after about 10 minutes:
Sorry but I don't know of a way to view cpu usage in 98.Code:#include <iostream>
#include <cstdlib>
using namespace std;
int main(void)
{
cout << "Hit the <any> key to continue" ;
system("pause");
return 0;
}
Looks like those tools become available for win2000 and up.
I'm pretty sure Win98 had a task manager with a process tab and CPU usage.
I think the bigger problem is that DOS-boxes in Win98 do not end up in Windows IDLE in the same way that a Win NT onwards DOS box does. DOS boxes in Win98 have completely different underlaying software functions, so it may well be that "PAUSE" doesn't stop the CPU from running at 100%.
--
Mats
The examiner is quite obviously an idiot, but there's not much we can do.