I’m sure you have stumbled across this before but I have perused through the issues and can’t seem to fine someone stuck specifically where I am.
Currently I have everything scripted to allow for user input greater than 0 and less than 8 as required. The pyramid structure is created but I cannot get it to build from right to left. I have tried multiple nested loop layouts and always get a similar structure to this:
(# )
(# #)
(# # #) *ignore the parenthesis as they are only there to eliminate the tag formatting.
Where the spaces are added in between each hash instead of compiled as a group prior.
Here is my code:
void print_blocks(int length);
int main(void)
{
int height;
do
{
height = get_int("Height: "); //prompts user input of integer
}
while (height < 1 || height > 8);
for (int i = 0; i < height; i++) //loops through to print the rows
{
print_blocks(i + 1); //calls the input value
}
}
void print_blocks(int length) //function to print # on row's
{
for (int i = length + 1; i > length; i--)
{
for (int l = 0; l < length; l++)
{
printf("#");
}
printf(" ");
}
printf("\n");
}