Shouldn't that be just strlen(str)?