I've spend half day reading the site for anything that could help me answer my doubts, but no success. After many tribulations I wrote down a code I thought would finally work but no such luck. It seems like everything I can make up is a block of hashes, with height and base given by the GetInt()
function. I've tried for hours to figure out where the mistakes are, but the problem is that I have doubts on many parts of my code.
for (num_line = 0; num_line < height; num_line++)
{
for (num_spaces = height - 1; (num_spaces <= 0); num_spaces--)
{
printf(".");
}
for (num_hash = 2; num_hash <= height + 1; num_hash++)
{
printf("#");
}
printf("\n");
}
For example, I read online that num_hash <= height + 1
is the correct syntax, instead of num_hash = height + 1
. Why is that?
I declared my variables before the do-while
loop, without initializing them.
Please, help me solve this program. Why doesn't it print out at all the spaces? And why does the number of hashes on each row remain constant, without starting as two and increment from there?
Sorry if my English is a little bit rusty, it's not my mother language!