char[n][100]是什么意思?

char[n][100]是什么意思?,c,C,我的教授给了我一个C文件,我不能很好地理解它。 这是一个从文本文件读取的程序 #include <stdio.h> main(){ int n,m; char start[30],end[30]; FILE *a; a=fopen("test.txt","r"); fscanf(a,"%s",&start); fscanf(a,"%s",&end); fscanf(a,"%d",&m); fsca

我的教授给了我一个C文件,我不能很好地理解它。 这是一个从文本文件读取的程序

#include <stdio.h>
main(){
    int n,m;
    char start[30],end[30];
    FILE *a;
    a=fopen("test.txt","r");
    fscanf(a,"%s",&start);
    fscanf(a,"%s",&end);
    fscanf(a,"%d",&m);
    fscanf(a,"%d",&n);
    printf("\n%s\n%s\n%d\n%d",start,end,m,n);
    char word[n][30];
    int i=0;
    while(!feof(a)){
        fscanf(a,"%s",&word[i]);
        i++;

    }

    for(i=0;i<n;i++)
        printf("\n%s",word[i]);
    fclose (a);

}
所以,我想知道这个字符[n][30]是什么意思?为什么它有[n]

所以,我想知道这个字符[n][30]是什么意思

从技术上讲,它是一个二维字符VLA。在该程序中,它用于存储n个字,其中每个字的最大长度为30个字符

为什么它有[n]

它是一个用于存储文件中字数的变量


看看你的程序,你可能必须输入8作为n的值

如果您有单词,那么n是从文件中读取的数字。
这就像文件的第一行中存储了一些参数一样

这是一个可变长度数组,一个C99功能。它是一个由100个字符的n个数组组成的数组。在一个无关的注释中,请阅读您可能想将链接转发给您的教授。哦,我现在明白了。谢谢为什么不问问你的教授这是什么意思?
blah alooa
7 4
hey
boom
stackoverflow
testing