I'd like to take array's size as input but not declaring before. How to do it.
I'd like to take array's size as input but not declaring before. How to do it.
Thats not possible in C. c++ would work. or dynamic arrays would work
C99 allows you to do this
In all versions, you can doCode:int size; scanf("%d", &size); int array[size];
Code:int size; scanf("%d", &size); int *array = malloc( size * sizeof(*array) );
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Tell me about this dynamic arrays. how could I possibly use them.
@Salem : thanks.