0

我已经提交了代码,请帮助我。该程序是关于创建一个字符串数据结构,用于仅包含字母 a 的字典。

[   #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    char *string[1000];
    /*This program is about creating a string data structure 
     *for 'a' alphabet only.
     */
    main()
    {
        char buffer[50];
        int i=0,size = 0;
        FILE *fp = fopen("A_dict.txt","r");
        while(fgets(buffer,1000,fp)!=NULL)
        {
            string[size] = (char *)malloc(strlen(buffer)+1);
            strcpy(string[size],buffer);
            size = size + 1;
        }
            string[size] = NULL;
        printf("the size of string array is %d\n",size);
        printf("The content are:\n");
        for(i = 0; i < size; i++)
        {
            puts(string[i]);
        }
        fclose(fp);
    }]

这些是我得到的错误 -

在此处输入图像描述

4

0 回答 0