Monday, September 21, 2009

Display() function

The challenge is to modify io_display function to the shortest code possible.
We don't need to go through the for() loop twice.
We can put condition inside the loop:

void io_display(const char *str, int row, int col, int len){
int i;

io_move(row, col);

(len <= 0) && io_putstr(str);

for(i=0; i<len ;i++)
str[i] ? io_putch(str[i]): io_putch(' ');
}

No comments:

Post a Comment