pointerproblems

Discussion in 'Mac Programming' started by jamesapp, Apr 7, 2008.

  1. macrumors 6502a

    Joined:
    Mar 7, 2008
    #1
    james-collinss-macbook-pro:prog13 jamescollins$ ./prog13.10
    Today's date is 9/25/.24.

    got this output when i tried to run a program from a book.

    here is my test program which i called prog13.10.m

    Code:
    // program to illustrate structure pointers
    #import <stdio.h>
    
    int main (int argc, char *argv[])
    {
      struct date
      {
      int month;
      int day;
      int year;
      
     };
     
     struct date today, *datePtr;
     
     datePtr = &today;
     datePtr ->month = 9;
     datePtr ->day = 25;
     datePtr ->year = 2004;
     
     printf ("Today's date is %i/%i/.2%i. \n",
          datePtr->month, datePtr->day, datePtr->year %100);
     return 0;
     
    }
    [code]
    
    for the year my program says .24 instead of 04
    any help would be appreciated.
     
  2. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #2
     

Share This Page