我已提交代码请帮帮我。该程序是关于创建一个字符串数据结构,仅包含字母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);
}]