#include<stdio.h>
int main() {
//system("cls");
char randomStr[] = "0123456789";
printf("\n\n\n\n\t\t\t\t\t");
while(!kbhit()) {
int i;
for(i = 0;i < 10;i++) {
printf("%c", randomStr[i]++);
while(randomStr[i] == '\n' || randomStr[i] == '\r' || randomStr[i] == '\t' ||
randomStr[i] == '\b' || randomStr[i] == '\0' || randomStr[i] == '\a' ||
randomStr[i] == '\v' || randomStr[i] == '\f') {
randomStr[i]++;
}
}
printf("\b\b\b\b\b\b\b\b\b\b");
}
return 0;
}
I want the cursor to move to a bit right and start printing characters and then overriding themselves which produces a sort of scrolling effect (like in lottery machines). This works fine without using system("cls")
but if I use system("cls")
the cursor is pulled back to the beginning of the line. Images below:
Without system("cls")
it works fine (chars in image are random, at an instance while program is running)
After adding system("cls")
this happens (the highlighted area is where my intended effect is taking place)