Hey guys, I am writing a program to output a half pyramid of hashes, although when I go to compile it says the variable "height is unused" even though I have declared it with the GetInt().
Code:
#include <stdio.h>
#include <cs50.h>
int main(void)
{
int height,line,hash;
do
{
int height = GetInt();
}
while (height>=1 || height<=23);
for(int line=1;line<=height;line++)
{
for(int hash=1;hash<=(line+1);hash++)
{
printf("#");
}
printf("\n");
}
return 0;
}
Code:
error: unused variable 'height' [-Werror,-Wunused-variable] int height = GetInt();