|
-
May 20th, 2002, 11:09 AM
#1
Thread Starter
Hyperactive Member
Hi.. Long Time No Seen!!!
It's been a while since my last post here!!
anyways, i'm trying to create a "Press any key to continue" in my code...
for example, i have to display 100 numbers.. each time the counter gets to 24, i should display the message, so the user gets to read the result... i think getch() is the way to do it, but i'm not sure about the exact code???
Please, help!! Thanx...
Here's the code i'm using by the way (the "Press..." only displays after the user presses a key.. starng, ha??!!):
Code:
#include <iostream.h>
#include <conio.h>
void main()
{
for (int i = 1; i <= 100; i++)
{
cout<<i<<endl;
if (i % 24 == 0)
{
cout<<"Press any key to continue";
getch();
}
}
}
"And Now I'm Lika Major Threat, Cause I Remind U Of The Things U Were Made To Forget!" - (2PAC)
"Now They Label Me a Lunatic, Couldn't Care Less, Death or Success is What I Quest, Cause I'm Fearless!" - (2PAC)
" There's a light at the end of every tunnel, just pray it's not a train!! "
I am 100% addicted to Tupac. What about you?
I am 24% addicted to Counterstrike. What about you?
The #1 Tupac Fans Web Site | The Official Tupac Web Site
-
May 20th, 2002, 11:37 AM
#2
Addicted Member
system("pause");
does the job for you, it prints out the text automatically
-
May 20th, 2002, 11:45 AM
#3
Thread Starter
Hyperactive Member
-
May 20th, 2002, 02:54 PM
#4
Addicted Member
try this:
PHP Code:
#include <iostream>
#include <conio> //not needed
using namespace std; //standard namespaces
int main()
{
for (int i = 1; i <= 100; i++)
{
cout<<i<<endl;
if (i % 24 == 0)
system("pause");
}
return 0;
}
-
May 20th, 2002, 05:44 PM
#5
Frenzied Member
I think you need to include stdlib.h for that:
PHP Code:
#include <stdlib.h>
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
May 24th, 2002, 09:30 AM
#6
better would be
#include <cstdlib>
cause we're talking C++ here...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 24th, 2002, 10:50 AM
#7
Frenzied Member
Yep you're right CornedBee..
the thing is.. I don't need to include anything now? Since I'm using VS.NET... is it true that you don't need to include any headers for it in .NET? or is it that I'm using namespace std; ?
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
May 24th, 2002, 11:16 AM
#8
No, I don't think so. Maybe you don't need to include anything for .NET, but I'd say you still have to include headers for normal programming.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 24th, 2002, 12:04 PM
#9
Frenzied Member
No I don't use managed extensions or whatever.. I just mean that I'm using VC7 (is there any difference between the includes needed for VC6 and VC7)
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
May 27th, 2002, 07:43 AM
#10
No, the CRT and C++ standard libraries stay roughly the same, as does the C++ syntax. There is no difference in including between VC6 and VC7. (I'd say, but I don't have VC7)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|