|
-
Apr 24th, 2001, 03:33 AM
#1
Thread Starter
Frenzied Member
Yesterday I wanted to clear the screen in my Console app, so I called the function clrscr(); which used to be a part of the conio.h file, but it wasn't there!! Why is that??
-
Apr 24th, 2001, 10:02 AM
#2
Addicted Member
clrscr() is a non standard function. It's only borland's Implementation.
so You have to include stdlib.h
and use
system("cls");
-
Apr 24th, 2001, 05:46 PM
#3
New Member
I'm glad you brought this up...I was working on a console app and had the same problem.
Later,
Paul
-
May 1st, 2001, 08:50 PM
#4
Fanatic Member
Sorry but this function dosen't work for me, can u specify some example code? I know this is really simple, but when i use
system("cls");
it wont do anything!
i included stdlib.h and im using VC++ 6.0 SP4
Thanks!
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
May 1st, 2001, 11:07 PM
#5
Frenzied Member
Check the definition in the MSDN, make sure you're using it correctly. It should work fine for console apps.
Harry.
"From one thing, know ten thousand things."
-
May 1st, 2001, 11:39 PM
#6
Fanatic Member
Code:
int main()
{
cout << "HELLO WORLD" << endl;
system("cls");
return 0;
}
i included the stdlib.h and all, just dint put it in the code.
is that right?
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
May 1st, 2001, 11:52 PM
#7
Frenzied Member
In a VC++ console app, paste the following code in:
Code:
#include <iostream>
#include <stdlib.h>
int main()
{
std::cout << "Hello World" << std::endl;
system("cls");
return 0;
}
<iostream> is the standard header, as opposed to <iostream.h> which is the Microsoft version. The standard library functions, structs and classes are in the std namespace so cout and endl are qualified with the scope resolution operator, ::. This works just the same:
Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
cout << "Hello World" << endl;
system("cls");
return 0;
}
but by using the standard namespace you will be declaring all your variables in that namespace, which kind of defeats the point of namespaces and might make your code awkward to reuse if you want it in a different namespace.
To be honest it doesn't matter much for this but I just felt like doing it properly 
Both examples compiled and ran fine for me. They end up with a blank screen.
Harry.
"From one thing, know ten thousand things."
-
May 1st, 2001, 11:58 PM
#8
Fanatic Member
-
May 2nd, 2001, 09:34 AM
#9
[QUOTE]Originally posted by HarryW
Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
cout << "Hello World" << endl;
system("cls");
return 0;
}
[\QUOTE]
cstdlib is the standard header for stdlib.h.
so the code would be:
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
cout << "Hello World" << endl;
system("cls");
return 0;
}
-
May 2nd, 2001, 11:24 AM
#10
Frenzied Member
Yes I'm well aware of that Dennis, but I wasn't sure if the system() function was M$-specific, so I used their version.
So back at ya
Harry.
"From one thing, know ten thousand things."
-
May 2nd, 2001, 12:34 PM
#11
Monday Morning Lunatic
cstdlib merely #includes stdlib.h inside the std namespace
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 2nd, 2001, 05:52 PM
#12
Originally posted by invitro
Sorry but it does not.
Did you remember to include the header file?
-
May 2nd, 2001, 10:31 PM
#13
Addicted Member
Originally posted by HarryW
Yes I'm well aware of that Dennis, but I wasn't sure if the system() function was M$-specific, so I used their version.
So back at ya
I am using the same system function to clear my screen in linux 
system("clear");
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
|