What I have is a string with some numbers (unknown amount but has a maximum), for example char string[] = "12 13 14 123 1234 12345"; and I wanna add each number to an array. So let's say I have an array int numbers[50]; and I want to add it to the array so it's like {12, 13, 14, 123, 1234, 12345}.
I've tried a loop through the string that uses a variable as a state machine to detect if it is reading a number but the code ended up looking like spaghetti so I just lost the way I was thinking. I cannot use malloc() or anything that allocates memory for this exercise.
Any ideas?
strtolin a loop using the second parameter to move the pointer to the next space.