Is is possible that I write a function such that either mystruct or example can be the type of one variable?
No. Every function parameter has exactly one type. Even though your two structs have members of the same type, in the same order, with the same names, they are distinct, incompatible types as a result of having different struct tags. (The difference in typedefed names, on the other hand, is irrelevant for this purpose.) A function that accepts an argument of one of those types, or a pointer to that type, cannot accept an argument of the other type into the same parameter.
It is possible that someone will recommend casting a pointer to one of those types to be a pointer to the other type, so as to be able to pass it to your hypothetical function. Whereas in practice that may yield the desired result, it nevertheless violates C's strict aliasing rule, and therefore produces undefined behavior. That kind of behavior can get you into trouble with an aggressively-optimizing compiler.
You have at least three options:
Use the same structure
There is no reason apparent from your question why you need distinct types, as the two types in question differ only in their struct tags. If you simply choose one and use it everywhere, then the problem disappears. You can typedef multiple aliases for that type if you wish; it does not then affect your code's validity which of those you use in any particular place.
Embed the same structure
It may be that you have oversimplified your code by removing elements of your two types that actually differ. In that case, you could embed a common structure containing those values into the larger structure, like so:
struct list_data {
entry* list_e;
int nb_elements;
int nb_mllc;
};
typedef struct example {
struct list_data list_data; // must be first
char *characters;
} example;
typedef struct mystruct {
struct list_data list_data; // must be first
int x, y, z;
} mystruct;
C guarantees that the representation of the first member of a structure will start at the first byte of the overall structure's representation. Therefore, you can (in principle) safely cast back and forth between a pointer to the first member and a pointer to the overall structure, as long as you're careful in the latter case to cast to the correct type.
Use a node type with discriminator and union
Casting is generally a sign of poor design. If you cannot use the same type everywhere, then it might be a better plan to turn the embedding idea inside out:
typedef struct example {
char *characters;
} example;
typedef struct mystruct {
int x, y, z;
} mystruct;
struct list_data {
entry* list_e;
int nb_elements;
int nb_mllc;
_Bool is_mystruct;
union {
example *example;
mystruct *mystruct;
};
};
Now you have a single type, struct list_data, that you can link together into lists via a single set of functions. That type can reference (or embed, if you prefer) either an example or a mystruct, with member is_mystruct disambiguating which is actually stored. Or if it will be evident from context which type is stored, then you can drop is_mystruct.
exampleandmystructappear to be identical except for their tags. Why not just choose one and use it everywhere?