clrscr in linux!

Posted on December 6, 2008. Filed under: Software | Tags: , , , |

Along the lines of the previous post One command called ‘clear’, I wrote a small C program that does clrscr().


/* clrscr in linux! */

#include <stdio .h>

void clrscr(void)
{
	char str[] = " [H [2J";
	str[3] = str[0] = 27;
	write(1, str, 7);
}

int main(int argc, char **argv)
{
	clrscr();
	printf("Hello World\n");

	return 0;
}

Disclaimer : May not work! :)

Make a Comment

Make a Comment: ( 2 so far )

blockquote and a tags work here.

2 Responses to “clrscr in linux!”

RSS Feed for Brain Dump Comments RSS Feed

Worked here.

I guess that having no clrscr shocks many people :-) When I started programming in Linux many years ago my first shock was not having “getch” and haskey (or something like that, a function that would tell you whether there’s a key in the buffer). Fortunately I ran into ncurses later…

system(“clear”);


Where's The Comment Form?

  • Feed

  • Ohloh

  • Bookmarks

  • Categories

  • Visitors


  • Hits

    • 22,597 hits

Liked it here?
Why not try sites on the blogroll...