I have been asked to write a code that receives a type of data without being specific about what type (example, int, float, double ect..) and its certainly a number. The code is simple, find a number in the array and return it's location in the array. This is the code i wrote:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int findselectnum(int num, int array[], int size)
{
    int i = 0;
    for (i = 0; i <= size; i++)
    {
        if (num == array[i])
            return i;
    }
    return EOF;
}
int main()
{
    int array[] = { 1, 3, 5, 10, 88, 21, 100, 77, 0, 11, 2 }, num = 0, result = 0, size = 0;
    printf("Enter a number you wish to find\n");
    scanf("%d", &num);
    size = sizeof(array);
    result = findselectnum(num, array, size);
    if (result != EOF)
        printf("The number %d is in array[%d]\n", num, result);
    else
        printf("The number does not exists on the array");
}
As you can see, i can only use the int type, so numbers that are float, or double, wont get the same result. So how can i use all types of data? Is there some kind of a structure for that? Thanks in advance.
 
     
     
    