Home Forums C Programming Linker Error while Compiling

Viewing 0 reply threads
  • Author
    Posts
    • #2102
      mayer1
      Participant

      Code genrated:

      /*
      *********************************************************************************************************
      *                                                Turbo C
      *
      *                          (c) Copyright 2001-2002, M.Appavu Raj, Chennai, TN
      *                                           All Rights Reserved
      *
      * File : ARRAY_GAME.C
      * Usage : Write a C program to generate a game of moving numbers
      * By   : M.Appavu Raj
      *********************************************************************************************************
      */
      /*
      *********************************************************************************************************
      *                                           LIBRARY/HEADER INCLUDES
      *******************************************************************************************************
      */
      #define MAX_ARRAY_INDEX 100
      #include
      #include
      #include"dos.h"
      #define PASSWORD_CODE 6066
      #define ACCESS_GRANTED 1
      #define ACCESS_DENIED 0
      #define OPERATION_VALID 1
      #define OPERATION_INVALID 0
      #define UPPER_KEY 72
      #define RIGHT_KEY 77
      #define LEFT_KEY  75
      #define DOWN_KEY  80
      /*
      *********************************************************************************************************
      *                                            FUNCTION DECLARATIONS
      *********************************************************************************************************
      */
      int key_detection(void);
      void blank_space_detection(int ,int array[][4],int ,int );
      int operation_validation(int ,int array[][4],int );
      void table_operation(int array[][4],int ,int ,int );
      int password_check(int *);
      void display_table(int array[][4],int );
      /*
      *********************************************************************************************************
      *                                            KEY DETECTION
      * Definition : Up key : 72,Down Key : 80,left Key : 75, Right key : 77
      *********************************************************************************************************
      */
      int key_detection()
      {
       union REGS i,o;
       while (!kbhit())
       ;
       i.h.ah=0;
       int86(22,&i,&o);
       return(o.h.ah);
      }
      /*
      *********************************************************************************************************
      *                                            Blank Space Detection
      *********************************************************************************************************
      */
      void blank_space_detection(int array_size,int *array[4][4],int row,int column)
      {
       for (int i=0;i  {
        for (int j=0;j   {
         if ((*(array + j)) == 0)
         {
          row =i;
          column = j;
          break;
         }
        }
       }
      }
      /*
      *********************************************************************************************************
      *                                            Operation Validation
      *********************************************************************************************************
      */
      int operation_validation(int key_type,int *array[4],int array_size)
      {
       static int i,right_key = OPERATION_VALID;
       switch (key_type)
       {
        case UPPER_KEY:
        {
         for (i=0;i    {
          if (*(array[0]+i) == 0)
          right_key = OPERATION_INVALID;
         }
         break;
        }
        case RIGHT_KEY:
        {
         for (i=0;i    {
          if (*(array+(array_size-1)) == 0)
          right_key = OPERATION_INVALID;
         }
         break;
        }
        case LEFT_KEY:
        {
         for (i=0;i    {
          if (*(array + 0) == 0)
          right_key = OPERATION_INVALID;
         }
         break;
        }
        case DOWN_KEY:
        {
         for (i=0;i    {
          if (*(array[(array_size-1)] + i) == 0)
          right_key = OPERATION_INVALID;
         }
         break;
        }
        default:
         printf("n CAUTION : Enter a Valid Key");
         right_key = OPERATION_INVALID;
         break;
       }
       return right_key;
      }
      /*
      *********************************************************************************************************
      *                                            Table Operation
      *********************************************************************************************************
      */
      void table_operation(int *array[4],int key_type,int blank_space_row,int blank_space_column)
      {
       switch (key_type)
       {
        case UPPER_KEY:
        {
         (*(array[blank_space_row]+blank_space_column) = *(array[(blank_space_row+1)]+blank_space_column));
         *(array[(blank_space_row+1)]+blank_space_column) = 0;
         break;
        }
        case RIGHT_KEY:
        {
         (*(array[blank_space_row]+blank_space_column) = *(array[blank_space_row]+(blank_space_column+1)));
         *(array[blank_space_row]+(blank_space_column+1)) = 0;
         break;
        }
        case LEFT_KEY:
        {
         (*(array[blank_space_row]+blank_space_column) = *(array[blank_space_row]+(blank_space_column-1)));
         *(array[blank_space_row]+(blank_space_column-1)) = 0;
         break;
        }
        case DOWN_KEY:
        {
         (*(array[blank_space_row]+blank_space_column) = *(array[(blank_space_row-1)]+blank_space_column));
         *(array[(blank_space_row-1)]+blank_space_column) = 0;
         break;
        }
        default:
         printf("n CAUTION : Enter a Valid Key");
         break;
       }
      }
      /*
      *********************************************************************************************************
      *                                            Password Check
      *********************************************************************************************************
      */
      int password_check(int *password)
      {
       int access;
       if(*password == PASSWORD_CODE)
       {
        access = ACCESS_GRANTED;
       }
       else
       {
        access = ACCESS_DENIED;
       }
       return access;
      }
      /*
      *********************************************************************************************************
      *                                            Array Display
      *********************************************************************************************************
      */
      void display_table(int *array[4],int array_size)
      {
       for (int i=0;i  {
        printf("ntt");
        for (int j=0;j   {
         printf("%dt",*(array+j));
        }
       }
      }
      /*
      *********************************************************************************************************
      *                                            MAIN FUNCTION
      *********************************************************************************************************
      */
      void main(void )
      {
       int array[4][4]={{1,4,15,7},{8,10,2,11},{14,3,6,13},{12,9,5,0}};
       int password,key_press,blank_row,blank_column;
       int valid_operation_key;
       clrscr();
       printf("n The Entered Table is :");
       display_table(array,4);
       printf("nPlease Enter your Key selection:");
       key_press = key_detection();
       blank_space_detection(4,array,blank_row,blank_column);
       valid_operation_key = operation_validation(key_press,array,4);
       if(valid_operation_key == OPERATION_INVALID)
       {
        printf("nEnter a valid Key");
       }
       else
       {
        table_operation(array,key_press,blank_row,blank_column);
        display_table(array,4);
       }
       getch();
      }

       
      I had a problem in linking as Undefined Symbol for alll the function which used the multi dimensional array as the argument. Can any one please clarify on it.

Viewing 0 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.