can you give an example?
What is the equivalent clrscr(); and getch(); from C to C++? And what is the syntax?
You can use same.
Include the #include%26lt;conio.h%26gt;
Console Input Output file is meant for these console i/o Functions. either you include in .C program or in .cpp . It will work.
and then you can call the same functions like
clrscr();
getch(); getchar(); getche();
etc;
**************************************...
#include%26lt;iostream.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
clrscr();
cout %26lt;%26lt; "Welcome to C++" %26lt;%26lt; endl;
getch();
}
Reply:hey I am not sure why clrscr is not workuing But try this too.
include %26lt;iostream.h%26gt;
#pragma hdrstop
#pragma argsused
int main(int argc, char* argv[])
{
cout %26lt;%26lt;"Test"%26lt;%26lt;endl;
system("cls"); getchar(); return 0;
} Report It
Reply:I am not much involved with C++. I am into EAI so still tries to help people. Donno when people like csanon will stop commenting others. Report It
Reply:First, clrscr() isn't part of the C or C++ standard library. That's right, conio.h is something shipped with your compiler, it's not part of C. So there is no equivalent from C to C++ because it doesn't exist in the first place. If you want to use clrscr, just include conio.h in C++ as well.
For getch(), the same is true. It is part of conio.h, which is not part of C or C++. If you want to use, include conio.h, but it won't compile everywhere (not everyone will have conio.h because it is not part of C++).
Panky, there's a couple of issues I have with your code.
First, C++ went through an update nearly a decade ago. One of them is that standard library include names don't have a .h. I recommend you revise your C++ knowledge. It should be #include %26lt;iostream%26gt;. You need a using namespace std directive if you want to avoid the namespace qualifier on cout and endl.
Finally, it is not void main. It is int main. Your code won't compile on an ISO compliant compiler. Or at least, it will raise a warning.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment