Empowering CS learners, aspiring programmers, and startups with AI, Data Science & Programming insights — scaling skills from learning foundations to enterprise-grade solutions.
#include <stdio.h>
#include <cs50.h>
int main (void)
{
int number;
printf ("enter a number ");
scanf ("%i", &number);
printf ("the number entered is %i", number);
}
[/dm_code_snippet]
Gradually, I am to let the user enter integer between 1 and 8. If anything else is entered, the cursor will wait till the user enters integer between 1 and 8 (Mario World 1-1). The Hints apparenty prescribes to use get_int.
My query is if a similar objective cannot be by scanf. What is the difference between scanf and get_int? Is get_int better, more powerful?