我有如下所示的输入文件
5
8
10
实际上,我需要在上面的示例中读取更多行的文件。(中间没有空格。因此,我需要让数组的大小取决于文本文件的行。这是我使用的方法发生 r
#include "stdafx.h"
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
int _tmain(int argc, _TCHAR* argv[])
{
    FILE *test;
    int numbers[]={0};
    int i=0;
    char *array1;
    if((test=fopen("Input1.txt","r"))==NULL)
    {
        printf("File could not be opened\n");
    }
    else
    {
        array1 = (char*)malloc(1000*sizeof (char));
        if((test=fopen("Input1.txt","r"))==NULL)
        {
            printf("File could not be opened\n");
        }
        else
        {
            while(fgets(array1,(sizeof array1)-1,test)!=NULL) 
            {
                numbers[i]=atoi(array1);
                i++;
            }
            for(i=0;i<sizeof(array1)-1;i++)
            {
                printf("%d\n",numbers[i]);
            }
        }
    fclose (test);
    }
    system("pause");
    return 0;
    free(array1);
}