Array with undefined length in C

后端 未结 3 490
半阙折子戏
半阙折子戏 2021-01-21 09:12

i was watching an exercise in my textbook that says: Create a C program that take from the keyboard an array with length \"N\".

The question is: In C language, how can i

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-21 09:43

    for more information about VLA in c99 The New C:Why Variable Length Arrays?

    #include 
    
    
    int main(){
        int n;
    
    
        printf("size of array: ");
        scanf("%d",&n);
        // limit, and erro verification omited
        int f[n],i;
    
        printf("\nREADING INPUT\n");    
        for(i=0;i

提交回复
热议问题