Why won't my variable nextSpaceIterator update to the index of the space following nextSpace?
int firstSpace = 0;
int nextSpace = 0;
int nextSpaceIterator = 0;
nextSpace = someInputString.IndexOf((char)ConsoleKey.Spacebar);
//find next space
Console.WriteLine(someInputString.Substring(firstSpace, nextSpace - firstSpace));
// Print word between spaces
firstSpace = nextSpace;
// Starting point for next step is ending point of previous step
nextSpaceIterator = someInputString.IndexOf((char)ConsoleKey.Spacebar, nextSpace);
// Find the next space following the previous one, then repeat.
Originally I used a for loop but I've broken down the code into individual statements to try to find the problem and I can't. Everything works up until this point. Shouldn't
nextSpaceIterator = someInputString.IndexOf((char)ConsoleKey.Spacebar, nextSpace);
return a different value than nextSpace?