Results 1 to 13 of 13

Thread: clrscr(); ???

  1. #1

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    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??
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  2. #2
    Addicted Member Active's Avatar
    Join Date
    Jan 2001
    Location
    Lat: 13° 4' 46" N, Long: 80° 15' 20" E
    Posts
    209
    clrscr() is a non standard function. It's only borland's Implementation.

    so You have to include stdlib.h

    and use

    system("cls");
    If you can't beat your computer at chess, try kickboxing !!!
    [Download Tag Editing Tools.]

  3. #3
    New Member
    Join Date
    Jan 2001
    Posts
    11
    I'm glad you brought this up...I was working on a console app and had the same problem.

    Later,
    Paul

  4. #4
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547

    Unhappy

    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?

  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  6. #6
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547
    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?

  7. #7
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  8. #8
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547

    Unhappy

    Sorry but it does not. Thank you for the reply, but i think this is a problem here. The computer i tried this on is running fortress security, and maybe they locked us out of certain things.

    I will try this at home and let you know what happens.

    Thanks alot for all the posts,
    greatly appriciated



    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?

  9. #9
    denniswrenn
    Guest
    [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;
    }

  10. #10
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  11. #11
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  12. #12
    Megatron
    Guest
    Originally posted by invitro
    Sorry but it does not.
    Did you remember to include the header file?

  13. #13
    Addicted Member Active's Avatar
    Join Date
    Jan 2001
    Location
    Lat: 13° 4' 46" N, Long: 80° 15' 20" E
    Posts
    209
    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");
    If you can't beat your computer at chess, try kickboxing !!!
    [Download Tag Editing Tools.]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width