clrscr();

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

32 Replies - 57733 Views - Last Post: 26 April 2009 - 09:29 PM Rate Topic: -----

#1 eLliDKraM  Icon User is offline

  • Pepè Le Pewn
  • member icon

Reputation: 6
  • View blog
  • Posts: 6,565
  • Joined: 13-August 05

clrscr();

Posted 26 November 2005 - 07:50 PM

I've been seeing more and more clrscr();'s typed into programs and decided that it would be more efficient than just typing many /n's :P. However, whenever I type clrscr();, it will not build because it cannot find the function clrscr. How am I seeing it work with other programs where it does not work with mine?
Is This A Good Question/Topic? 0
  • +

Replies To: clrscr();

#2 jaredolympia  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 29
  • Joined: 15-October 05

Re: clrscr();

Posted 26 November 2005 - 08:25 PM

Are you trying to find a function that clears the screen? If you are, I ran into that problem a little while ago. This should do the trick if you're running the program in MSDOS (non-ansi code). The clrscr() function might be compiler specific. Either way, I really don't know why to be honest.

system("CLS");


The following site contains more DOS commands:
EasyDOS Command Index

Hope this helps!

Sincerely,
jaredolympia

This post has been edited by jaredolympia: 27 November 2005 - 12:50 AM

Was This Post Helpful? 0
  • +
  • -

#3 eLliDKraM  Icon User is offline

  • Pepè Le Pewn
  • member icon

Reputation: 6
  • View blog
  • Posts: 6,565
  • Joined: 13-August 05

Re: clrscr();

Posted 26 November 2005 - 08:55 PM

That does not seam to work either. For both clrscr and this, I am supposedly missing the prototype.
Was This Post Helpful? 0
  • +
  • -

#4 Mrafcho001  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 41
  • View blog
  • Posts: 769
  • Joined: 01-November 05

Re: clrscr();

Posted 26 November 2005 - 09:11 PM

Clearing The Screen

system("cls"); should work just fine
clrscr() is in conio.h
Was This Post Helpful? 0
  • +
  • -

#5 eLliDKraM  Icon User is offline

  • Pepè Le Pewn
  • member icon

Reputation: 6
  • View blog
  • Posts: 6,565
  • Joined: 13-August 05

Re: clrscr();

Posted 26 November 2005 - 09:15 PM

Yeah I include conio.h. It doesn't work.

EDIT: Using Dev C++ and PellesC compilers.

This post has been edited by eLliDKraM: 26 November 2005 - 09:16 PM

Was This Post Helpful? 0
  • +
  • -

#6 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: clrscr();

Posted 26 November 2005 - 11:32 PM

Here's a little hint...none of the functions you have specified are ANSI compliant. conio.h itself is not ANSI compliant. Non ANSI compliant code is only usable in some compilers or platforms. If you use it, your code is automatically not cross platform compliant.

I know there is a tendancy these days to learn code, and come up with habits that are specific to certain platforms/compilers...this is not acceptable as a professional developer.

N/M...I'll write an article about it. It's important.
Was This Post Helpful? 0
  • +
  • -

#7 jaredolympia  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 29
  • Joined: 15-October 05

Re: clrscr();

Posted 27 November 2005 - 01:02 AM

Using system("cls") works on Dev-C++. Perhaps you are using an outdated version. You can run the following code to check.

#include <stdio.h>

int main(void)
{
    puts("Hello");
    system("PAUSE");
    system("CLS");
    system("PAUSE");
    return 0;
}

Attached File(s)

  • Attached File  cls.zip (5.54K)
    Number of downloads: 547

This post has been edited by jaredolympia: 27 November 2005 - 01:04 AM

Was This Post Helpful? 0
  • +
  • -

#8 Wizzy  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 6
  • View blog
  • Posts: 408
  • Joined: 20-November 05

Re: clrscr();

Posted 27 November 2005 - 04:36 AM

These never used to exist for C++, it was C's source code.

Check your compiler environment while i test this,
Was This Post Helpful? 0
  • +
  • -

#9 microchip  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 37
  • Joined: 14-August 05

Re: clrscr();

Posted 27 November 2005 - 05:16 AM

But you can use C code in C++, so if you plan to use conio.h, there's nothing stopping you...

Just a thought, wouldn't sending a newpage ASCII code clear the screen?
Was This Post Helpful? 0
  • +
  • -

#10 Wizzy  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 6
  • View blog
  • Posts: 408
  • Joined: 20-November 05

Re: clrscr();

Posted 27 November 2005 - 05:31 AM

umm even if i use that program including either stdlib or stdio i get the msg:

Quote

ISO C++ does not support 'long long'


(using latest version)
Was This Post Helpful? 0
  • +
  • -

#11 microchip  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 37
  • Joined: 14-August 05

Re: clrscr();

Posted 27 November 2005 - 06:45 AM

Argh yeah, you're right about that. Maybe putting

extern "C" {
}

around the #include would help...
Was This Post Helpful? 0
  • +
  • -

#12 eLliDKraM  Icon User is offline

  • Pepè Le Pewn
  • member icon

Reputation: 6
  • View blog
  • Posts: 6,565
  • Joined: 13-August 05

Re: clrscr();

Posted 27 November 2005 - 10:13 AM

I'm using the newest version of Dev C++ and I use it to compile C and
#include <stdio.h>

int main(void)
{
   puts("Hello");
   system("PAUSE");
   system("CLS");
   system("PAUSE");
   return 0;
}
does not work.
Was This Post Helpful? 0
  • +
  • -

#13 Wizzy  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 6
  • View blog
  • Posts: 408
  • Joined: 20-November 05

Re: clrscr();

Posted 27 November 2005 - 05:36 PM

ahh some coding misuse thats all, i found the answer here

#include <iostream>//needs these three lines
#include <stdlib.h>//needs these three lines
using namespace std;//needs these three lines

int main(int argc, char *argv[])
{
        cout << "A simple Demonstartion of system(\"cls\");" << endl;
        system("PAUSE");
        system("cls");//clears the screen
        cout << "The first two lines are gone" << endl;
        system("PAUSE");
        return 0;
}


it seems to be the latest version of iostream that fixed it (without .h meaning latest)

This post has been edited by Wizzy: 27 November 2005 - 05:38 PM

Was This Post Helpful? 0
  • +
  • -

#14 eLliDKraM  Icon User is offline

  • Pepè Le Pewn
  • member icon

Reputation: 6
  • View blog
  • Posts: 6,565
  • Joined: 13-August 05

Re: clrscr();

Posted 27 November 2005 - 05:41 PM

I code in C, though.
Was This Post Helpful? 0
  • +
  • -

#15 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: clrscr();

Posted 27 November 2005 - 05:49 PM

Wizzy, on 27 Nov, 2005 - 08:33 PM, said:

it seems to be the latest version of iostream that fixed it (without .h meaning latest)

The functionality avaiable in <iostream> and <iostream.h> is the same...the removal of the .h merely indicates the deprecation of the old header style libraries used in C and C++...the accepted standard now is to use namespaces.

As I noted above, the ability to use something like clrscr() or system("cls") depends on the availabilty of that process on your platform...not your compiler, but your platform.
Open a command window...type cls an hit enter...if your screen clears, then you can use the command. Just keep in mind that it will work on your machine...it may not work on others (I guarantee there are machines upon which it will not work). This does not matter if it is for personal use, but you cannot include code like that in applications developed for deployment in a commercial sense...it is not standards compliant.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3