Also you are using a global variable for number... Why? That defeats the purpose of functions. Move that
int number;
inside of main() and use the sizeOfBox parameter in your function.
Ok as of right now you are filling the middle of the square with *'s.
Lets take a look at how it should look if the user enters the number 5 for example
*****
* *
* * (More like a rectangle but it works for now.)
* *
***** |
Now we already got the top and the bottom done. So we can ignore that. What we need to do it take care of the middle 3 asterisks on each side and the spaces in the middle.
I made a mistake by telling you that you needed to have nested loops, sorry about that. We actually only need to use one loop that will print out each row of the box. Though we need to make a little change to the loop like so.
for (int row = 0; row < sizeOfBox - 2; row++)
The reason why we minus 2 from the max number is because the top and bottom rows make up 2 rows already. So no matter what number the user enters the middle part will always be 2 rows less then that.
Next we need to take a look at the cout statement. Since we are printing a whole row at a time it is much easier to figure out. All you need to do is print the first '*' then the correct number of spaces in the middle and the ending '*'.
Hopefully this helps, not sure if I explained it that well.
Hint: After you figure out how to make a rectangle you might need to change it so that it prints a square instead depending on how your assignment is worded. To do this you are going to have to change the parts that print the top and bottom part of the box.