does a similar function clrscr() from conio.h exists in gcc ?
does a similar function clrscr() from conio.h exists in gcc ?
Well, you can use system("cls") . . . check the FAQ.
[edit]
Found it: http://faq.cprogramming.com/cgi-bin/...&id=1043284385
[/edit]
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Assuming you're using Linux you should have a look at ncurses. I'm sure you will not have problems finding a nice tutorial.
yes, i know that... but i'm looking for smthing portable from linux to win. another way not using any external commands ?
Every option that I know of listed in the FAQ - there is no universal solution in the standard.
thank you!
really helps!
I believe I have tried to use different ways to clear the screen, but almost everyone of them takes a lot of time and (I think) memory.
I think I tried adding a lot of spaces using "for"
I hope that will save you some time!
Alastor
"I tend to use my inbox as a todo list. But that's like using a screwdriver to open bottles; what one really wants is a bottle opener" - Paul Graham
This works, but it doesn't position the cursor at (0,0). If you can live with that, fine, otherwise you need to call a function to set the cursor (the FAQ has a Windows version).I think I tried adding a lot of spaces using "for"
For portability, you could use the preprocessor:
Code:void clear_screen(void) { #ifdef unix /* not standard, but usually defined */ clrscr(); #else system("cls"); #endif }
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I'm almost completely sure that clrscr is a Borland invention for MS-DOS/Windows based systems and isn't available on a Unix system. If you're lucky, putchar('\f') might work, but otherwise you'll be doing something system-dependent or relying on a loop or a system call.Originally Posted by dwks
Okay, then, on UNIX use system("clear");.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Or just realise that the vast majority of command line tools do not begin with any attempt to clear the screen. If they did, they would soon become majorly annoying just to look at and probably majorly annoying if you attempted to say pipe the output to another program.
The typical evolution of a programmer
Day 1 - discover '\a' and abuse it
Day 2 - discover clearing the screen and abuse it
Day 3 onwards - concentrate on providing useful tools rather than trying to impose your ego on the users.
>Day 1 - discover '\a' and abuse it
>Day 2 - discover clearing the screen and abuse it
Presumably because they got tired of abusing '\a'.
>Day 3 onwards - concentrate on providing useful tools rather than trying to impose your ego on the users.
Only two days of abuse? You've been extremely lucky in the programmers that you've known.
Code:void main() { #define woobly "stdio.h" #include woobly while (1 ) printf ("\a" ); return 'q';}