• Skip to main content
  • Skip to footer

CS50's Introduction to Computer Science on Edx: Supplementary resource

CS50 threads to aide as a supplementary resource

Type int in scanf

CS50 threads to aide as a supplementary resource › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 1 › Type int in scanf

Tagged: arguments, format string, int type, pointers, printf, scanf, variables

  • This topic is empty.
Log In Register Lost Password
Viewing 1 post (of 1 total)
  • Author
    Posts
  • August 5, 2021 at 8:27 am #89
    admin
    Keymaster


      Copy Code
      Copied
      Use a different Browser

      
      
      #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/ $ 
      
      

      Reply


      https://cs50.stackexchange.com/questions/41771/type-int-in-scanf[learn_press_profile]

    • Author
      Posts
    Log In Register Lost Password
    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Log In

    Log in / Register

    Initiative by Digital Splendid OPC Pvt. Ltd.