0

What is wrong in this

#include <graphics.h> #include <stdlib.h> #include <conio.h> #include<dos.h> int main() { /* request auto detection */ int gdriver = DETECT, gmode; /* initialize graphics mode */ initgraph(&gdriver, &gmode,"C:\\TurboC3\\BGI"); //font for(int i=1;i<450;i++) { cleardevice(); settextstyle(1,0,5); move to(250+i,200); setcolour(BLUE); outtext("RAJ"); move to(250,200+i); setcolour(YELLOW); outtext("RAJ"); move to(250-i,200); setcolour(WHITE); outtext("RAJ"); move to(250,200-i); setcolour(PINK); outtext("RAJ"); move to(250,200); setcolour(RED); outtext("RAJ"); delay(10); } /* clean up */* getch(); closegraph(); return 0; }

4th Jan 2022, 8:55 AM
AGW GAMING
2 Answers
+ 1
AGW GAMING do you know why it doesn't work on code playground? because code playground doesn't support those MS-DOS headers(graphics.h conio.h and dos.h are the part of MS-DOS non-standard library) which is too old to use it today.
4th Jan 2022, 10:22 AM
Rellot's screwdriver
Rellot's screwdriver - avatar
0
let's assume that you're using it for legacy or out of curiosity you're trying to output "RAJ" in different colors and positions very rapidly(which is impossible to see with our eyes) and then you're delaying it, iterating it 450 times! what you should do is after updating the output's position and color, set the delay function below that, for every change so you could see it. here's the example(I don't use MS-DOS, I modified it just by looking at the function name) for(int i = 1; i < 450; i++){ cleardevice(); settextstyle(1,0,5); move to(250+i,200); setcolour(BLUE); outtext("RAJ"); delay(10); move to(250,200+i); setcolour(YELLOW); outtext("RAJ"); delay(10); move to(250-i,200); setcolour(WHITE); outtext("RAJ"); delay(10); move to(250,200-i); setcolour(PINK); outtext("RAJ"); delay(10); move to(250,200); setcolour(RED); outtext("RAJ"); delay(10); }
4th Jan 2022, 10:40 AM
Rellot's screwdriver
Rellot's screwdriver - avatar