[Vala] How should an array be dynamically allocated?



This is what I attempted:
/** convert a string (of the form output by to_string) into the fields
    *    of the current instance    */
    void    str2bib(string str)
    {    int    i    =    count(str, @"$gs");
        string    sflds[]    =    new    string [i];
        sflds    =    str.split(@"$gs");
    }
/**    returns the number of times delim occurs within str    */
int    count (string str, string delim)
{    int    i, res;
    for    (i = 0, res = 0;    i <= str.length - delim.length;    i++)
    {    if    (str[i: i + delim.length] == delim)    res++;    }
    return    res;
}

The Vala compiler likes it, but c doesn't (array size missing, incompatible types when assigning to type 'char*[1]' from type 'char**', etc.)





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]