This program will move designed object (arrow sign "==>") on screen without use of <graphics.h> and system("cls") or clrscr() function.
#include <stdio.h>
#include <windows.h>
COORD c = {0, 0};
void setxy (int x, int y)
{
c.X = x; c.Y = y; // Set X and Y coordinates
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
int main()
{
int i;
for(i=0; i<20; i++)
{
system("color A1");
setxy(i, 5);
printf("==>");
setxy(i-3, 5); //For clearing previous position of arrow
printf(" ");
Sleep(200);
}
return 0;
}
Output of Program
This program will move ==> sign on screen from Left side to Right side.
#include <stdio.h>
#include <windows.h>
COORD c = {0, 0};
void setxy (int x, int y)
{
c.X = x; c.Y = y; // Set X and Y coordinates
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
int main()
{
int i;
for(i=0; i<20; i++)
{
system("color A1");
setxy(i, 5);
printf("==>");
setxy(i-3, 5); //For clearing previous position of arrow
printf(" ");
Sleep(200);
}
return 0;
}
Output of Program
This program will move ==> sign on screen from Left side to Right side.
No comments:
Post a Comment