|
-
January 6th, 2003, 10:09 AM
#11
Senior Member
WTF, ive never used Bloodshed before, use turbo, simple and best 
but shantz is right, getch(); is a function and one word.
And shantz, getch() is included in iostream, except if you're using a 2-3 year old compiler.
What command was that er0k ?
I don't think commands change when compilers change.
I mean i neva heard o that one before.
One more thing, does Bloodshed dominate users in America ?
duh, i mean the compiler.
\"I have a 386 Pentium.\"
-
January 6th, 2003, 10:19 AM
#12
Originally posted here by M/S Vin
Erok, this one worked! Thanks! I appreciate it, and if you have some more to add please feel free to do so.
np... anytime, im also new to C++ just have been through that b4 
invader >> that is the function you use with the standard library's on a simple output statement for it to stay "on screen" you can use the system('pause') as well its just not always portable. the cin.ignore() function is built in..
edit >> sometimes its good practice to try something similar to this: ( if you are doing std work)
#include <iostream>
using namespace std;
-
January 6th, 2003, 10:22 AM
#13
Senior Member
\"I have a 386 Pentium.\"
-
January 6th, 2003, 10:25 AM
#14
its a built in function yes, and iostream is a pre-processor directive that contains it yes to be frank. sorry id get you some more info from muuuucccch better programmers, ie a C++ book, but i need sleep.
-
January 6th, 2003, 11:10 AM
#15
C++ uses streams for input and output (this replaces C's printf() scanf() although still availible).
Streams are in fact objects....
You have four console streams automatically availible: cin, cout, cerr, clog
cin reads from the console (standard input), cout writes to the console (standard output)...
cin is an istream (actually it's derived from istream...)
the class istream defines, amonst others, the operator ">>" (ie: operator>>() )
which you use to read from a stream, in cin's case the stream is the standard input so it "reads from the keyboard".
cout is an ostream
the class ostream defines the operator "<<" (ie: operator<<() )
which you use to write to a stream, in cout's case the standard output, so it "writes to the screen".
as for cin.ignore():
ignore() is a method of the class istream; by default (without params) it reads 1 character (or up to EOF) from the standard input ("keyboard") and discards it. Ie: it makes the application wait for the user to enter a character before continuing...
Hope this clears things up...
Ammo
Credit travels up, blame travels down -- The Boss
-
January 6th, 2003, 03:03 PM
#16
The function getch() and the Alt+F5 combo work only with Turbo/Borland C++. So you have to use system("pause"); instead.
Cheers,
cgkanchi
-
January 6th, 2003, 03:06 PM
#17
Senior Member
as for cin.ignore():
ignore() is a method of the class istream; by default (without params) it reads 1 character (or up to EOF) from the standard input ("keyboard") and discards it. Ie: it makes the application wait for the user to enter a character before continuing...
urmm...doesnt getch() do the same ? Get a character from the user before continuing..
Thanks anyway, ammo
\"I have a 386 Pentium.\"
-
January 6th, 2003, 03:25 PM
#18
#include<stdlib.h>
#include<conio.h>
#include<iostream.h>
void main(){
cout<<"Hello world";
cout<<"\npress any key to quit....";
while(getch()=='\0'){
}
_exit(0);
}
-
January 6th, 2003, 06:24 PM
#19
Originally posted here by invader
WTF, ive never used Bloodshed before, use turbo, simple and best 
Im in enough confusion as it is.
Originally posted here by cgkanchi
The function getch() and the Alt+F5 combo work only with Turbo/Borland C++. So you have to use system("pause" ; instead.
Cheers,
cgkanchi
System pause didn't work either, and I get the message Implicit declaration of function int getch (...) But thanks.
Originally posted here by black_death
#include<stdlib.h>
#include<conio.h>
#include<iostream.h>
void main(){
cout<<"Hello world";
cout<<"\npress any key to quit....";
while(getch()=='\0'){
}
_exit(0);
}
I've tried the one you PM, it compiled successfully but It didn't run.
Anymore help/info that you want to add, feel free to do so.
Thank you for all the help .
Light thinks it travels faster than anything but it is wrong. No matter how fast light travels it finds the darkness has always got there first, and is waiting for it. -Reaper Man
-
January 6th, 2003, 06:33 PM
#20
To use the system("pause") command you have to #include <cstdlib> at the beginning of the program. If that doesn't work, use #<stdlib.h>. And if that still doesn't work, get a real compiler at http://borland.com.
Cheers,
cgkanchi
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
|
|