关于Malloc char ***的断点

时间:2017-01-29 20:00:20

标签: c char malloc breakpoints

我有一个项目要完成......为此我需要一个字符来获取文本文件(对于翻译者)所有字词名称。 我的程序总是在strcpy上断点(a [line] [v [i]],p);我被卡住了numar_cuvinte = word_number linie = line

while (!feof(dictionary_list))
{
    fgets(buffer, 100, dictionary_list);
    p = strtok(buffer, "-.\n");
    while (p != NULL)
    {

        if (p != "txt")
        {
            nr_cuvinte++;
            p = strtok(NULL, "-.\n");
        }
        else
            p = NULL;
    }
    v[linie] = nr_cuvinte;  // ---------> v[i] = nr cuvinte pe linie 
    nr_cuvinte = 0;// ----->m
    linie++; // --->n
}
//-------------------------------------------------------------------------
a = (char***)malloc(linie*sizeof(char**));

for (int i = 0; i < linie; i++)
{
    a[i] = (char**)malloc(v[i] * sizeof(char*));
}

for (int i = 0; i < linie; i++)
{
    for (int j = 0; j < v[i]; j++)
    {
        a[i][j] = (char*)malloc(20 * sizeof(char));
    }
}
//--------------------------------------------------------------------------
rewind(dictionary_list);
linie = 0;
nr_cuvinte = 0;
while (!feof(dictionary_list))
{
    fgets(buffer, 100, dictionary_list);
    p = strtok(buffer, "-.\n");
    while (p != NULL)
    {
        if (p != "txt")
        {

            strcpy(a[linie][v[nr_cuvinte]], p);
            nr_cuvinte++;
            p = strtok(NULL, "-.\n");
        }
        else p = NULL;

    }
    v[linie] = nr_cuvinte;
    nr_cuvinte = 0;// ----->m
    linie++; // --->n
}

}

0 个答案:

没有答案