lundi 4 juin 2018

How can I return reference to element in array in this case?

Given arrays of pointers, if I want to write a function that move about all the array and check if exists element with specific key (for example) , and if yes, I want to return exactly array[i] so that I will can to initialize this ceil again after calling to this function, for example:

func(array,size,key) = 3 --> array[i_key]=3 (it's a simple example, not of pointers like I writed above, for explain what I want).

But, can be case that key not exists in the array, and then I need to return null (at least, I think so). But I can not do it while I returns a reference.

Someone have idea how to solve this problem?

Aucun commentaire:

Enregistrer un commentaire