I am using an 2d array to search for the key 32 using pointers.. Now whenever i try to compile i get an linker error saying undefined symbol find_key(int *far,int,int)..
I know the error is with the use of pointers and the way i am passing them... Can anyone help me out
I know the error is with the use of pointers and the way i am passing them... Can anyone help me out
Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define N 4
void find_key(int *,int,int);
void main(){
clrscr();
srand((unsigned)time(NULL));
int arr[N][N];
int *p;
int key=32;
int len=16;
int count=0;
for(p=&arr[0][0];p<=&arr[N-1][N-1];p++){
if(count==4){
*p=32;
}
else{
*p=rand()%10+1;
}
count++;
}
for(p=&arr[0][0];p<=&arr[N-1][N-1];p++)
printf("\n%d",*p);
find_key(&arr[0][0],len,key);
getch();
}
void find_temp(int *a,int n,int k){
int *p;
for(p=a;p<a+n;p++){
if(*p==k)
printf("\nfound key at %d",p);
else
printf("\nnot foumd");
}
}
Comment