Click to See Complete Forum and Search --> : clear the screen in ansi c
agent
Feb 18th, 2001, 12:59 AM
i'm writing an ansi c program. how do you clear the text from the screen? (i'm brand new to c and c++)
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Text");
system("cls");
printf("More text");
return 0;
}
Blitz
Feb 20th, 2001, 08:59 PM
You can try this code and see:
[quote]
#include<stdio.h>
int main() {
int i;
printf("Old Page");
for(i = 0; i < 80; i++)
printf("\n");
printf("New Page!");
return 0;
}
that's just adding 80 new lines. It's easier to use the system() function.
parksie
Feb 21st, 2001, 02:41 PM
Yep -- and you can't guarantee the display size.
kourosh
Feb 21st, 2001, 10:24 PM
Hi, Sorry Parksie this is off topic but how do you get
Mike "parksie" Parks to be color gradient?
Thanks.
sail3005
Feb 21st, 2001, 10:28 PM
look at this post:
http://forums.vb-world.net/showthread.php?s=&threadid=54475
HarryW
Feb 21st, 2001, 10:40 PM
I take it screen clearing is platform dependant?
Blitz
Feb 21st, 2001, 10:46 PM
Yes that's why I use "\n"to create my own clear screen function. You will be able to use it regardless of platform.
HarryW
Feb 21st, 2001, 10:56 PM
True, but other platforms allow you to view different numbers of lines, so you can't be sure how many lines are visible.
sail3005
Feb 21st, 2001, 11:14 PM
well, there is always a limit to how many lines can fit on a screen, i doubt and would have more than 150. So if you were really parinoied you could do it for like 500 lines.
HarryW
Feb 21st, 2001, 11:36 PM
Hmmm well I don't know about 'always'... different platforms can allow for you to view a lot of lines. I'm sure you could add some platform-specific code to find out how many lines you needed, but then you might as well use the platform specific clear function.
parksie
Feb 22nd, 2001, 05:24 AM
Originally posted by kourosh
Hi, Sorry Parksie this is off topic but how do you get
Mike "parksie" Parks to be color gradient?
Both me and Active simultaneously wrote gradient programs -- he went for two-point while I did rainbow, so different people used that. I couldn't be bothered to do any more on mine so he put rainbow into his :)
agent
Feb 23rd, 2001, 03:30 AM
thanks for the help. I thought there would be a supplied CLS function or at least a \ command to do it.
Lord Orwell
Feb 27th, 2001, 12:57 AM
Are you programming for dos or just for a console?
agent
Mar 1st, 2001, 12:25 AM
console. However, i'm doing it through vb. I thought there might be a string you could send to stdout to clear the screen, and since most console-mode apps are written in c/c++ i though i'd have better luck asking here.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.