There are two major issues and a couple of other minor bugs that I'll let you find on your own later.
First, let's deal with the spaces.
for (space = height - line; space == 0; space--)
This line controls the printing of spaces. (You might want to change the space to something printable while you debug so you can count them.) Your thinking is that you want the for loop to stop when space gets to 0, or when the
space == 0 condition becomes true. The problem is that the for loop only executes the code while the condition is true and stops when it becomes false. Because of this, the for loop that prints spaces will only execute when
height - line equals 0. that only occurs at the end of the process. If, on the other hand, you used
space > 0, it will do much better.
Now, the printing of the hashes takes a little different remedy, even though it's a similar issue.
for (hash = height + 1; hash <= height + 1; hash++)
There are two issues here. First of all, remember that the test condition must be true for the loop to run. If hash = height + 1 to start, it will always be true the first time through, but with one incrementation of hash, it will be larger, so the test will fail.
The second problem is that you are basing your test on the full height of the pyramid. It needs to be stepped up as you print each row, so it needs to be based on the row number, not the height.
There's an old saying: KISS -- keep it simple, stupid! Not meant as an insult or a judgment, this is something I tell myself quite often and it saves me a lot of grief!! So, with that in mind, let's look at the hashes.
The first row always prints two hashes,
##. So, start with hash = 1. But what should the test condition be? Since you want two hashes in the first line, how about
line + 1? It makes it simple and gets you there fast. Here's a better test:
for (hash = 1; hash <= line + 1; hash++)
That should get you the pyramid. As was mentioned elsewhere, just delete the string input code. It's not needed. GetInt() will deal with any text inputs.
There's one more bug, but I'm sure you'll find it very quickly. ;-)
This is an older question, so you've probably finished the pset. However, if this or any other answer has satisfied your question, please mark one as the answer to this question so that it will close. Let's keep up on forum maintenance. ;-)