#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#define MAX 25
main(){
int a[MAX],i,j,lvl=2,score=0;
float time=1.0,speed;
speed=time/lvl;
clrscr();
for(i=0;i<MAX;i++)
a[i]=rand()%50+1;
while(1){
for(j=0;j<MAX;j++){
gotoxy(a[j],1);
printf("*");
gotoxy(1,1);
insline();
sleep(speed);
score++;
gotoxy(57,1);
clrscr();
printf("%d",score);
if(score==100)
lvl++;
}
}
}
Hi i'm trying to print the score on the upper right corner of the screen using gotoxy()
. I used gotoxy(1,1)
to set the cursor position where blank line should be inserted using insline()
. but everytime I printed the score on the screen, it's printing the score continous as shown below:
emphasized texts there other way to print the score and delete it on its last position when insline()
inserts a new line so that the last score will not be printed on the screen but the current score only?