I am writing in c. I want to make a character moving on screen while running time .I am thinking about using printf() which can print the screen after a specified number of white spaces using %s.
I am saving this number in a variable how can I use %s with variable not constant value
The code is
#include <stdio.h>
#include <stdlib.h>
int main()
{
int it=0;
int tr;
printf("T \n");
srand(time(NULL));
while(it != 80 )
{
tr=rand()%3+1;
switch(tr)
{
int tmove=it;
case 1 :{
if(80-it>1)
{
tmove+=1;
it+=1;
}
else it=80;
break;}
case 2 :{
if(80-it>2)
{
tmove=+2;
it+=2;
}
else it=80;
break;}
case 3 :{
if(80-it>3)
{
tmove+=3;
it+=3;
}
else it=80;
break;}
default:break;
}
printf("%s","T");
}
}
I want to make T printed after number of whitecaps equal to move.