I only started learning C 2 days ago, so sorry if this is kind of a dumb question, but I wanted to try and store a function that I could call with default arguments.
At the moment, I have a struct with 2 values. One is storing a pointer, and one is storing a function pointer named print.
struct List{
int **ptr;
int (*print)(int**);
};
At the moment, I am creating the struct with the following code:
struct List list;
list.ptr = ptr;
list.print = (&printList);
where printList is a function that takes a pointer as a parameter, and prints a list of values.
Currently the code works when I call the function with the paramater
list.print(list.ptr);
however, I want to be able to call it like this:
list.print();
Is this possible? If so, could you give me some ideas on how to implement it?
Thanks!