can we write a function in c, tht can accept any type of array, may tht be int, float, char, struct or of any any kind, as an argument and perform some task of tht like sorting etc.
Jump to Post
Of course you can. Declare the array parameter as a pointer to void, add a parameter that tells the function what the type is, use the type parameter in a switch statement or if-then-elses, and cast the array parameter appropriately in each case.
The afforementioned qsort function is only slight …
All 3 Replies
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.