Thread: error with scanf statement in codeblocks

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    45

    error with scanf statement in codeblocks

    I am new to c programming.I use codeblocks on windows xp.I get an error when I run the following code
    Code:
    #include <stdio.h>
    #include <conio.h>
    
    int  main()
    {
        int a;
        printf("enter a number\n");
        scanf("%d",&a);
        printf("you entered %d",&a);
        return 0;
    }
    the error says
    format %d expects type int
    but argument 2 has type int.

    please solve this
    Last edited by Salem; 03-19-2011 at 12:41 PM. Reason: Added [code][/code] tags

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    The error is not in scanf() ... and it's obvious.

    Figure it out yourself. Really, shouldn't take more than a couple of minutes...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. While Statement Issue.
    By mcertini in forum C++ Programming
    Replies: 6
    Last Post: 01-14-2011, 12:34 PM
  2. scanf with switch statement, weird behavior
    By ademkiv in forum C Programming
    Replies: 1
    Last Post: 11-22-2010, 10:49 AM
  3. Simple XOR Program
    By dolfaniss in forum C Programming
    Replies: 8
    Last Post: 05-24-2010, 01:27 PM
  4. some questions about scanf
    By winggx in forum C Programming
    Replies: 1
    Last Post: 03-28-2010, 06:16 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM