#include <stdio.h>
#include <cs50.h>
int main (void)
{
int number;
scanf ("enter a number %i", number);
}
The above is perhaps a starter program. Still struck. Number is type int and so I am using %i in the scanf command.
This is the error message:
mario.c:6:29: error: format specifies type 'int *' but the argument has type 'int' [-Werror,-
Wformat]
scanf ("enter a number %i", number);
~~ ^~~~~~
Be sure to use the correct format code (e.g., %i for integers, %f for floating-point values,
%s for strings,
etc.) in your format string on line 6 of mario.c.
~/pset1/ $
@RobertS.Pratt
#include <stdio.h>
#include <cs50.h>
int main (void)
{
int number;
scanf ("enter a number %i", &number);
printf ("the number is %i", number);
}
Putting & before the variable name in scanf worked. However, when I run, I do not receive "enter a number" text. Do I need to create/define any more variable that will hold that text? Also, printf do not return the integer that is entered from the keyboard as part of scanf.
Here is the result as I enter 44
~/pset1/ $ ./Mario
44
the number is 0~/pset1/ $