Quote:
The goal is to eliminate the need for heap or the stack data when using strtok's return.
What would be the point of that? Any variable needs stack or heap space, you can't just store data in the ether. Actually, char result1[16];
in your example is placed in the stack. What exactly have been "eliminated" here?
Quote:
In your example you are using the stack for the return from strtok. This is exactly what i'm trying to avoid.
Actually, strdup()
allocates memory on the heap. And my_tokens
array is a global variable, placed in RAM.
Quote:
My question is really more of about the syntax. Can you instruct the compiler to treat an array as a pointer for return types, specifically for strtok?
Even if you did that, you'd just have pointers in your array instead of character data, as you probably expect, and treating it as characters would produce garbage.
Once again, can you please explain the overall problem? Why don't you want to use heap or stack? I think you're approaching it from the wrong angle.
Does anyone know how to return from strtok into an array rather than a pointer?
Help is appreciated!!!