Based on your updated code (v4), change the following:
1. outer for loop head line change
i++
to
++row
2. inner for loop head line change
col < length
to
col < row
3. remove the while loop (I' m not even sure what you needed it for)
4. instead of
cout << ". ";
write
cout << "* ";
(you did want asterisks, no? ;))
5. Move the line
"cout << '\n';"
outside and behind the inner for loop
you didn't specify what form that pyramid shoud be, but with the changes above you should get sth like that:
*<br />
* *<br />
* * *<br />
* * * *<br />
Note that steps 2 and 3 change your program logic significantly, and I don't know if the results match your intention. But then you didn't state what the spaces are good for, or why you think you need a third nested loop when you are effectively addressing characters in a two-dimensional matrix. I don't see where you get that third dimension from.