in reply to confused with Inline::C again

C is not my love, but in Perl this is trivially easy:
use Modern::Perl; my @string = qw(a a b h a g s j s z u u e); for (1 .. @string) { say join '', @string; shift @string; }
Output:
aabhagsjszuue abhagsjszuue bhagsjszuue hagsjszuue agsjszuue gsjszuue sjszuue jszuue szuue zuue uue ue e
Update: Of course this routine clears @string, if you need its original contents, copy it into another array.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James