3 ms·
> I'm pretty sure you could add a function pointer argument to printNTriples and replace the printf() You could, but the control is still driven by printNTripl
by zvrba 13y ago
> I'm pretty sure you could add a function pointer argument to printNTriples and replace the printf()
You could, but the control is still driven by printNTriples. What if you had to break early, before generating all N triples? In this simple case, you could use a return value from the callback to decide whether to continue or not.
In a more general case, you would you would encapsulate the state into a class (for example, the x,y,z,i locals from the original function would become instance memebers.)