I am currently in the process of finishing Problem Set 1 from CS50 2019, which involves creating a pyramid out of hashes. The pyramid must be made by the user inputting a number between 1 and 8 (inclusive). I've gotten to the point where I ask the user for an integer between 1 and 8 and keep on asking until it is received. I have watched the walkthrough and seen the hints, but I am still confused as to how in the world to do this. Can someone please provide me with some insight on this? Here is my current code:
#include <cs50.h>
#include <stdio.h>
int get_positive_int(string prompt);
int main(void)
{
int i = get_positive_int("Height: ");
printf("Stored: %i\n", i);
}
// Ask for integer between 1 and 8
int get_positive_int(string prompt)
{
int n;
do
{
n = get_int("%s", prompt);
}
while (n > 8 || n <= 0);
return n;
}
Thanks!