Thread: Variable Error - please help!!

  1. #1
    Registered User
    Join Date
    Jan 2014
    Location
    Los Angeles, California, United States
    Posts
    14

    Variable Error - please help!!

    Here is the start of my C code. I only post the first few lines cause I finally pinned down the error to this mess.

    I am using bcc32 from the command line, I delete obj and tds files between compiles and still get bogus results: what am i doing wrong?? (stdio is included)
    int main ()
    {
    int n = 0;
    int d = 0;
    int m = 0;
    int y = 0;

    int day;
    char* answer;
    int z = 0;
    printf("Enter the day date in numeric format \n");
    scanf("%d",&d);
    printf("Enter the month in numeric format \n");
    scanf("%d",&m);
    printf("You entered %d \n",&m);

    I always end up with a huge number 168000 on the last printf statement even when 1 is entered at the prompt.

  2. #2
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    &m is a pointer to m... printf() doesn't want a pointer to m, it wants m

  3. #3
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Quote Originally Posted by Hodor View Post
    &m is a pointer to m... printf() doesn't want a pointer to m, it wants m
    Passing a pointer makes baby printf cry.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  4. #4
    Registered User
    Join Date
    Jan 2014
    Location
    Los Angeles, California, United States
    Posts
    14

    Thanks!!

    Quote Originally Posted by oogabooga View Post
    Passing a pointer makes baby printf cry.

    Thanks guys, I am now getting much easier to fix garbage! (you did solve my immediate issue!)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error in using free(*variable)
    By amalendu in forum C Programming
    Replies: 3
    Last Post: 01-21-2012, 08:01 AM
  2. Undeclared Variable Error
    By greendragons in forum C Programming
    Replies: 8
    Last Post: 12-21-2011, 08:48 AM
  3. Error in return variable.
    By jericjones45 in forum C++ Programming
    Replies: 2
    Last Post: 02-26-2009, 09:22 PM
  4. Class Variable = Error?
    By Denethor2000 in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2005, 12:36 PM
  5. variable redefinition error
    By 7smurfs in forum C++ Programming
    Replies: 4
    Last Post: 12-14-2004, 05:55 PM