hi:
we use system("cls") function in c++ i need a function or a class or any command that i give it in my code that clear my screen plz help me

Recommended Answers

All 4 Replies

Sadly, there is no command or functionality like that in the language. You could however call the system command to execute the console command, but that may not be what you want.

run time of java prgram we write simply cls in console window it clear the screen but i need a command that i give in my code it clear my screen autometically. and how to call system command to execute the console command.

as Taywin already said: "there is no command or functionality like that in the language"

By "screen" do you mean the console window, as in System.out? If so, be aware that the console output device may be to a printer or a sequential file, in which case "clear the screen" makes no sense, and attempting to execute a "cls" as a system command will have unpredicatable reuslts in such cases (and if you use the wrong command for the OS that happens to be running at the time). Also, as far as I can find out, there is no cls functionality in standard C++ either; it's just that some implementations of C++ have it as a non-standard addition.

Your safest option is just to send a load of newlines to the console device.

It's not worth spending any real effort on this - console I/O is used in the early stages of teaching Java, but you won't ever use it again except as a logging device for errors etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.