Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 将文件(包含字母和数字)读入两个二维数组_C_Arrays_Multidimensional Array - Fatal编程技术网

C 将文件(包含字母和数字)读入两个二维数组

C 将文件(包含字母和数字)读入两个二维数组,c,arrays,multidimensional-array,C,Arrays,Multidimensional Array,我需要帮助将文本文件读入两个二维数组。 文件数据示例:(每个名称的分数在一行中) 我需要将字母读入一个数组,将数字读入另一个数组。 我成功地将整个文件读取到一个二维数组中: FILE *infile; int i , j, c, nl = 0, cr = 0, col = 0, row = 0; infile = fopen("D.txt", "r"); while (fscanf(infile, "%c", &c) != EOF) { if (c == '\n')

我需要帮助将文本文件读入两个二维数组。 文件数据示例:(每个名称的分数在一行中)

我需要将字母读入一个数组,将数字读入另一个数组。
我成功地将整个文件读取到一个二维数组中:

FILE *infile;
int  i , j, c,  nl = 0, cr = 0, col = 0, row = 0;
infile = fopen("D.txt", "r");
while (fscanf(infile, "%c", &c) != EOF)
{
    if (c == '\n')
        nl++;
    if (c == '\r')
        cr++;

    col++;

    if (c == '\n')
        row++;
        putchar(c);}
col = (col - (nl + cr));
col = (int) (col/row);
row = row - row;
 char sn[row][col];
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            fscanf(infile,"%c", &sn[i][j]);}}
文件*infle;
int i,j,c,nl=0,cr=0,col=0,row=0;
infle=fopen(“D.txt”、“r”);
while(fscanf(填充、%c、&c)!=EOF)
{
如果(c=='\n')
nl++;
如果(c=='\r')
cr++;
col++;
如果(c=='\n')
行++;
putchar(c);}
col=(col-(nl+cr));
列=(int)(列/行);
行=行-行;
字符序号[行][col];

对于(i=0;i)你有具体的问题吗?你有具体的问题吗?
FILE *infile;
int  i , j, c,  nl = 0, cr = 0, col = 0, row = 0;
infile = fopen("D.txt", "r");
while (fscanf(infile, "%c", &c) != EOF)
{
    if (c == '\n')
        nl++;
    if (c == '\r')
        cr++;

    col++;

    if (c == '\n')
        row++;
        putchar(c);}
col = (col - (nl + cr));
col = (int) (col/row);
row = row - row;
 char sn[row][col];
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            fscanf(infile,"%c", &sn[i][j]);}}