Saturday, 24 August 2013

gotoxy() function using printf() 's position

gotoxy() function using printf() 's position

Hello there
i am working a project which need the gotoxy() function
i have read gotoxy() implementation for Linux using printf

i wonder why the

void gotoxy(int x,int y)
{
printf("%c[%d;%df",0x1B,y,x);
}
need to change the x y order in printf, is that just to fit the coordinate
system?
in my way, i change it to printf("%c[%d;%df",0x1B,x,y) to meet my needs

stil, during my using this gotoxy() in for loop like this:

for( int i = 0; i < 12; i++ ) {
for( int j = 0; j < 12; j++ ) {
gotoxy( i , j );
usleep(500000);
}
}
when i = 0 and i = 0, the cursor are on the first row
i wonder why cursor does't go to second row when i = 1?

No comments:

Post a Comment