I have seperate functions for reading from a text file (depending on whether its an int, float or double). I would like just one function with an additional argument (without using a subsequent IF statement). Does anyone have ideas?
Below is the form of my current functions.
float * read_column_f (char * file, int size_of_col){
...
col = (float*) malloc (height_row * sizeof(float));
... return(col);}
double * read_column_d (char * file, int size_of_col){
...
col = (double*) malloc (height_row * sizeof(double));
... return(col);}
int * read_column_i (char * file, int size_of_col){
...
col = (int*) malloc (height_row * sizeof(int));
... return(col);}
EDIT: I want to implement this in C++, the C-style syntax used is due to memory preference.