'Output several strings as a marquee separated by 9 characters

I've been following this post How to output a string in a marquee fashion? to output a marquee.

My problem is that I have a string composed of several strings separated by a character, in this case '-'. From string to string inside the marquee it needs to be 9 spaces of distance.

I have tried this code but the result is not the expected:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef _WIN32
    #include <windows.h>
#else
    #include <unistd.h>
#endif

void customSleep( int seconds )
{
    #ifdef _WIN32
        Sleep( 1000 * seconds );
    #else
        sleep( seconds );
    #endif
}

static char text[] = "STRING01-STRING02";
static char indexOfCharacterToPrint, i, currentStartPosition;
static char temp;
static char blanks;
static char imarquee;

int main() {
    while (1) {
        if (blanks == 0)
            indexOfCharacterToPrint = (currentStartPosition + imarquee) % strlen(text);
        temp = text[indexOfCharacterToPrint];
        if (temp == '-') {
            blanks++;
            temp = ' ';
            if (blanks == 9)
                blanks = 0;
        }
        printf("%c", temp);
        i++;
        imarquee++;
        if (imarquee == 16)
            imarquee = 0;
        if (i == 16) {
            i = 0;
            currentStartPosition++;
            customSleep(1);
            printf("\r");
        }
    }
}

The expected output is:

STRING01
TRING01         S
RING01         ST
ING01         STR
NG01         STRI
G01         STRIN
01         STRING
1         STRING0
         STRING02

The actual output is

STRING01        
 TRING02TRING01 
        TRING02S
ING01         ST
ING02STRNG01    
     TRING02STRI
01         STRIN
02STRING1       
  TRING02STRING0
STRING02STRING01
TRING02STRING01 
        RING02ST
ING01         ST

What I am missing?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source