#include <cs50.h>
#include <stdio.h>
int main(void)
{
int h = 0;
int g = h - 1;
do
{
h = get_int("Height: ");
}
while (h < 0 || h >= 9);
for (int x = 0; x < h; x++)
{
for (int ind = g; ind > 0 && g > 0; ind--)
{
printf(" ");
}
for (int y = 0; y <= x; y++)
{
printf("#");
}
printf("\n");
g--;
}
printf("%i\n", g);
}
That's is all my code above, and I don't get why if I'll try to compile it, thats happens: You can expect always -1, but it's even worse: -h - 1. I solve this by just replacing implementation of the int g after do while loop, then the whole function works properly. But still: why g = -h - 1, whet it goes right after h