Here is the solution without using strlen() function. It looks so confusing because I thought we should aviod using the strlen() function...Can you figure out my logic and help to improve it.
bool nullFound = false;
for (setPos(row, col), i = 0; i < (fieldLen == 0 ? fieldLen + 1 : fieldLen);
(!nullFound ? (nullFound = (str[i] == 0 ? true : false)) : nullFound = true),
fieldLen == 0 ? *this << str : (!nullFound ? putChar(str[i]) : putChar(' ')),
i++);
}