Friday, September 25, 2009

Challenge II

Here is my result for challenge 2, she works but she is ugly.

void io_display(const char *str, int row, int col, int len){
io_move(row, col);
len <=0?io_putstr(str);:{int i=0; while(len--) io_putch(str[i]?str[i++]:' ');}
return;}

In fact, I'll do one worse.

void io_display(const char *str, int row, int col, int len){
io_move(row, col);
len <=0?io_putstr(str);:{int i=0; while(len--) io_putch(str[i]?str[i++]:' ');}}

Since most compilers don't need the return to be specified. I'm not sure how she works in terms of efficiency, but this is a small piece of code IMO, and a great way to get your co-workers to hate you.

No comments:

Post a Comment