I am writing a C function GetDeviceList()
which must return a list of device names found as strings somehow. The number of devices found and of course the device names themselves will vary each time the function is called.
How the function gets the device names is not the scope of this question, but inside the GetDeviceList()
function, a char*
gets updated in a loop with each new device name found. This char*
must then be copied to a list which can be read by the caller.
The function, nor the calling function cannot use dynamic memory.
What would be the best way to get a list of those strings returned from the function. I am thinking of a 2-dimensional char array passed as an output paramater, but not sure.