nabeen
asked on
screen change color
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
void main()
{
int p=DETECT,q;
initgraph(&p,&q,"");
clrscr();
setbkcolor(BLACK);
printf("THIS IS A TEST PROGRAM");
getch();
}
In the following program has got no error and I understand every function I used above.
But whenever I use initgraph function and then clrscr() function I get 75% of my screen in any other color usually gray
and 25% is always black. I cannot correct it even if I use setbkcolor() after each clrscr() command.
I could not figure out what is wrong and which function is making problem.
PLEASE HELP................
#include<graphics.h>
#include<conio.h>
void main()
{
int p=DETECT,q;
initgraph(&p,&q,"");
clrscr();
setbkcolor(BLACK);
printf("THIS IS A TEST PROGRAM");
getch();
}
In the following program has got no error and I understand every function I used above.
But whenever I use initgraph function and then clrscr() function I get 75% of my screen in any other color usually gray
and 25% is always black. I cannot correct it even if I use setbkcolor() after each clrscr() command.
I could not figure out what is wrong and which function is making problem.
PLEASE HELP................
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi nabeen
u should use cleardevice() command to clear the screen in graphics mode. clrscr() is for text mode only.
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
void main()
{
int p=DETECT,q;
initgraph(&p,&q,"");
//------------------------ ---------- -
clrscr();// for text mode
cleardevice();//for graphics mode
//------------------------ ---
setbkcolor(BLACK);
printf("THIS IS A TEST PROGRAM");
getch();
}
u should use cleardevice() command to clear the screen in graphics mode. clrscr() is for text mode only.
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
void main()
{
int p=DETECT,q;
initgraph(&p,&q,"");
//------------------------
clrscr();// for text mode
cleardevice();//for graphics mode
//------------------------
setbkcolor(BLACK);
printf("THIS IS A TEST PROGRAM");
getch();
}
I've tried using the clrscr(); but it shows an error while compiling in Microsoft Visual C++ 6.0 . What libraries do i need to initialise in order to use the function?? How do i go about it using MS VC++ 6.0 as my compiler?
Just out of curiosity!
Just out of curiosity!
Try using _clrscr () ; instead of clrscr () ; and see if it works (include <conio.h>, of course).
_clrscr(); also does not work...
any other suggestions??
any other suggestions??
>> using MS VC++ 6.0 as my compiler
clrscr () is screen-based, and VC++ is window-based. clrscr () is supposed to clear the "screen". I guess VC++ starts the execution of your program in a cleared command window anyway (I've not worked much on VC++ - I'm more into Java.... that's why I don't have VC++ on my system too. I just have an old Turbo C++ compiler, which I'd used once while working with micro-controllers).
Mayank.
clrscr () is screen-based, and VC++ is window-based. clrscr () is supposed to clear the "screen". I guess VC++ starts the execution of your program in a cleared command window anyway (I've not worked much on VC++ - I'm more into Java.... that's why I don't have VC++ on my system too. I just have an old Turbo C++ compiler, which I'd used once while working with micro-controllers).
Mayank.
no..there is an ERROR while compiling...
that's what i mean by not working....
and even though MS VC++ is windows based, the programs created are run in DOS
that's what i mean by not working....
and even though MS VC++ is windows based, the programs created are run in DOS
The error must be that the function clrscr () is not defined/ declared or that it needs a prototype.
is it possible for u to post a working solution for this problem??
because i do not get what u mean!
because i do not get what u mean!
What is the error?
just a compiling error...says that clrscr () is not declared
Yeah! Like I said:
>> The error must be that the function clrscr () is not defined/ declared or that it needs a prototype.
Sorry, deejay, don't know how to help you with that on VC.
>> The error must be that the function clrscr () is not defined/ declared or that it needs a prototype.
Sorry, deejay, don't know how to help you with that on VC.
Yeah! Like I said:
>> The error must be that the function clrscr () is not defined/ declared or that it needs a prototype.
Sorry, deejay, don't know how to help you with that on VC.
>> The error must be that the function clrscr () is not defined/ declared or that it needs a prototype.
Sorry, deejay, don't know how to help you with that on VC.
ASKER
i want tsr of this function. can any one provide?
#include <conio.h>
#include <graphics.h>
#define RETURN_EXIT_SUCCESS 0
int main()
{
int driver,mode;
detectgraph(&driver,&mode)
initgraph(&driver,&mode,"C
cleardevice();
setbkcolor(BLACK);
printf("%s","THIS IS WAT YOU NEED. \n");
getch();
return RETURN_EXIT_SUCCESS;
}