n00b doesen't understand arrays in c... : I'm a super noob - as in i've been coding for less than a week. I'm just learning about arrays in c and I can't figure out the following for the life of me, why is the following not correct?

    string space_inserter (string s, int x)
    {
    string text = s;
    long long N = strlen(s);
    string a = s;
    long long c = 0;
    int z = x;
            for(int i = 0; i < N + (N/x) ; i++)
        {
              if( i == x)
            {
                a[c] = 32;
                c++;
                z = (z + x);
                printf("%c\n", a[c]);           
            }
            
            a[c] = text[i];
            printf("%c\n", a[c]); 
            c++;
        }
        //a[c] = '\0';
        return a;
}

It's meant to insert spaces into a string of text after every x chars... I know it's not efficient ( recon i need something called pointers) but why isn't it working. I went through it using a debugger and it seems like my original string is changing as i go... but why??

Thanks vm,

Tikhon