Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum type(INT,DOUBLE,LONG);
- #define CheckIfExist(arr, num, type, count, len)\
- {\
- int i;\
- type * ptr = (type *)arr;\
- type * nPtr = (type *) num;\
- for(i=0; i<len; i++, ptr++)\
- {\
- if(*ptr == *nPtr)\
- {\
- count = i+1;\
- }\
- }\
- }
- double BodekImKayam(void* arr,void* num, int type, int len)
- {
- double count =0;
- switch (type) {
- case INT: {
- CheckIfExist(arr, num, int, count, len);
- return count;}
- case LONG: {
- CheckIfExist(arr, num, long, count, len);
- return count;}
- }
- }
- int main ()
- {
- int arr[] = {1};
- int len = sizeof(arr)/sizeof(arr[0]);
- int num = 77;
- if (BodekImKayam(arr,&num,INT,len) == 0)
- printf("num not found");
- return 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement