Hello !
I'm trying to do a rotation of strings but I'm having trouble with the last element. Everything rotates the way I want but the final element always has the exact same contents from another mystery string appended to the end. The mystery string is declared and used outside of this function (and is not passed as a parameter to this function).
**The really strange thing to me is that the commented out 'fout' within the function show the last element to be exactly the strings that I expected. So what's going on ???
example output start:
sString[i] is
sString[i] is Lars52
sString[i] is HeyWanna
sString[i] is Pekar
sString[i] is peon3
sString[i] is burim 12
end:
sString[i] is
sString[i] is peon3
sString[i] is burim 12
sString[i] is Lars52
sString[i] is HeyWanna
sString[i] is PekarTHIS is the extra string appendedwtf???
Thanks! That'll help. I didn't make the mental connection that it could be used to rotate strings.
And.......
For completeness, any explanation for the mystery string ? I don't understand how the content of the final element could have changed within the loop (where it isn't supposed to change anymore) to just outside of the loop.
for(int i=0; i<=6; i++) was a typo sorry (program would crash with that line)
But it made me look in the right direction !!!
The problem was that I forgot to place a newline character after a previous call to fout in another function. Once the functions cycled, it looked like there was an extra mystery string being tacked onto the end of these, when in fact it was the first string sent to fout from the next function.