I have this simple program in which I initialize a string with "HELLO". I need the output to be printed as HLOEL, i.e) all the even indexes (0,2,4) followed by the odd ones (1,2). I could not infer what's wrong with my code, but it yields "HLOELHLO" instead of "HLOEL". Could someone explain what is happening here?
#include <stdio.h>
int main() {
    int i,loPos=0,hiPos=0;
    char *str="HELLO";
    char lo[2];
    char hi[3];
    for(i=0;i<5;i++)
    {
        if(i%2==0)
        {
            hi[hiPos++]=str[i];
        }
        else
        {
            lo[loPos++]=str[i];
        }
    }
    printf("%s%s",hi,lo);
    return 0;
}
Thanks in Advance!
 
     
    