Home › Forums › C Programming › Linker Error while Compiling
- This topic has 0 replies, 1 voice, and was last updated 16 years, 7 months ago by mayer1.
Viewing 0 reply threads
- AuthorPosts
- May 14, 2008 at 2:15 am #2102mayer1Participant
Code genrated:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229/*<br />*********************************************************************************************************<br />* Turbo C<br />*<br />* (c) Copyright 2001-2002, M.Appavu Raj, Chennai, TN<br />* All Rights Reserved<br />*<br />* File : ARRAY_GAME.C<br />* Usage : Write a C program to generate a game of moving numbers<br />* By : M.Appavu Raj<br />*********************************************************************************************************<br />*/<br />/*<br />*********************************************************************************************************<br />* LIBRARY/HEADER INCLUDES<br />*******************************************************************************************************<br />*/<br />#define MAX_ARRAY_INDEX 100<br />#include<stdio.h><br />#include<conio.h><br />#include"dos.h"<br />#define PASSWORD_CODE 6066<br />#define ACCESS_GRANTED 1<br />#define ACCESS_DENIED 0<br />#define OPERATION_VALID 1<br />#define OPERATION_INVALID 0<br />#define UPPER_KEY 72<br />#define RIGHT_KEY 77<br />#define LEFT_KEY 75<br />#define DOWN_KEY 80<br />/*<br />*********************************************************************************************************<br />* FUNCTION DECLARATIONS<br />*********************************************************************************************************<br />*/<br />int key_detection(void);<br />void blank_space_detection(int ,int array[][4],int ,int );<br />int operation_validation(int ,int array[][4],int );<br />void table_operation(int array[][4],int ,int ,int );<br />int password_check(int *);<br />void display_table(int array[][4],int );<br />/*<br />*********************************************************************************************************<br />* KEY DETECTION<br />* Definition : Up key : 72,Down Key : 80,left Key : 75, Right key : 77<br />*********************************************************************************************************<br />*/<br />int key_detection()<br />{<br />union REGS i,o;<br />while (!kbhit())<br />;<br />i.h.ah=0;<br />int86(22,&i,&o);<br />return(o.h.ah);<br />}<br />/*<br />*********************************************************************************************************<br />* Blank Space Detection<br />*********************************************************************************************************<br />*/<br />void blank_space_detection(int array_size,int *array[4][4],int row,int column)<br />{<br />for (int i=0;i<array_size;i++)<br />{<br />for (int j=0;j<array_size;j++)<br />{<br />if ((*(array + j)) == 0)<br />{<br />row =i;<br />column = j;<br />break;<br />}<br />}<br />}<br />}<br />/*<br />*********************************************************************************************************<br />* Operation Validation<br />*********************************************************************************************************<br />*/<br />int operation_validation(int key_type,int *array[4],int array_size)<br />{<br />static int i,right_key = OPERATION_VALID;<br />switch (key_type)<br />{<br />case UPPER_KEY:<br />{<br />for (i=0;i<array_size;i++)<br />{<br />if (*(array[0]+i) == 0)<br />right_key = OPERATION_INVALID;<br />}<br />break;<br />}<br />case RIGHT_KEY:<br />{<br />for (i=0;i<array_size;i++)<br />{<br />if (*(array+(array_size-1)) == 0)<br />right_key = OPERATION_INVALID;<br />}<br />break;<br />}<br />case LEFT_KEY:<br />{<br />for (i=0;i<array_size;i++)<br />{<br />if (*(array + 0) == 0)<br />right_key = OPERATION_INVALID;<br />}<br />break;<br />}<br />case DOWN_KEY:<br />{<br />for (i=0;i<array_size;i++)<br />{<br />if (*(array[(array_size-1)] + i) == 0)<br />right_key = OPERATION_INVALID;<br />}<br />break;<br />}<br />default:<br />printf("n CAUTION : Enter a Valid Key");<br />right_key = OPERATION_INVALID;<br />break;<br />}<br />return right_key;<br />}<br />/*<br />*********************************************************************************************************<br />* Table Operation<br />*********************************************************************************************************<br />*/<br />void table_operation(int *array[4],int key_type,int blank_space_row,int blank_space_column)<br />{<br />switch (key_type)<br />{<br />case UPPER_KEY:<br />{<br />(*(array[blank_space_row]+blank_space_column) = *(array[(blank_space_row+1)]+blank_space_column));<br />*(array[(blank_space_row+1)]+blank_space_column) = 0;<br />break;<br />}<br />case RIGHT_KEY:<br />{<br />(*(array[blank_space_row]+blank_space_column) = *(array[blank_space_row]+(blank_space_column+1)));<br />*(array[blank_space_row]+(blank_space_column+1)) = 0;<br />break;<br />}<br />case LEFT_KEY:<br />{<br />(*(array[blank_space_row]+blank_space_column) = *(array[blank_space_row]+(blank_space_column-1)));<br />*(array[blank_space_row]+(blank_space_column-1)) = 0;<br />break;<br />}<br />case DOWN_KEY:<br />{<br />(*(array[blank_space_row]+blank_space_column) = *(array[(blank_space_row-1)]+blank_space_column));<br />*(array[(blank_space_row-1)]+blank_space_column) = 0;<br />break;<br />}<br />default:<br />printf("n CAUTION : Enter a Valid Key");<br />break;<br />}<br />}<br />/*<br />*********************************************************************************************************<br />* Password Check<br />*********************************************************************************************************<br />*/<br />int password_check(int *password)<br />{<br />int access;<br />if(*password == PASSWORD_CODE)<br />{<br />access = ACCESS_GRANTED;<br />}<br />else<br />{<br />access = ACCESS_DENIED;<br />}<br />return access;<br />}<br />/*<br />*********************************************************************************************************<br />* Array Display<br />*********************************************************************************************************<br />*/<br />void display_table(int *array[4],int array_size)<br />{<br />for (int i=0;i<array_size;i++)<br />{<br />printf("ntt");<br />for (int j=0;j<array_size;j++)<br />{<br />printf("%dt",*(array+j));<br />}<br />}<br />}<br />/*<br />*********************************************************************************************************<br />* MAIN FUNCTION<br />*********************************************************************************************************<br />*/<br />void main(void )<br />{<br />int array[4][4]={{1,4,15,7},{8,10,2,11},{14,3,6,13},{12,9,5,0}};<br />int password,key_press,blank_row,blank_column;<br />int valid_operation_key;<br />clrscr();<br />printf("n The Entered Table is :");<br />display_table(array,4);<br />printf("nPlease Enter your Key selection:");<br />key_press = key_detection();<br />blank_space_detection(4,array,blank_row,blank_column);<br />valid_operation_key = operation_validation(key_press,array,4);<br />if(valid_operation_key == OPERATION_INVALID)<br />{<br />printf("nEnter a valid Key");<br />}<br />else<br />{<br />table_operation(array,key_press,blank_row,blank_column);<br />display_table(array,4);<br />}<br />getch();<br />}
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.
- AuthorPosts
Viewing 0 reply threads
- The forum ‘C Programming’ is closed to new topics and replies.