i'm writing an ansi c program. how do you clear the text from the screen? (i'm brand new to c and c++)
Printable View
i'm writing an ansi c program. how do you clear the text from the screen? (i'm brand new to c and c++)
Code:#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Text");
system("cls");
printf("More text");
return 0;
}
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.
Yep -- and you can't guarantee the display size.
Hi, Sorry Parksie this is off topic but how do you get
Mike "parksie" Parks to be color gradient?
Thanks.
look at this post:
http://forums.vb-world.net/showthrea...threadid=54475
I take it screen clearing is platform dependant?
Yes that's why I use "\n"to create my own clear screen function. You will be able to use it regardless of platform.
True, but other platforms allow you to view different numbers of lines, so you can't be sure how many lines are visible.
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.
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.
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 :)Quote:
Originally posted by kourosh
Hi, Sorry Parksie this is off topic but how do you get
Mike "parksie" Parks to be color gradient?
thanks for the help. I thought there would be a supplied CLS function or at least a \ command to do it.
Are you programming for dos or just for a console?
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.