At compiling time, the definition of an array should have a specific length, else that is a compiling error, you can use dynamic allocation way to define the array if you do not know the length.
i.e.
char* str=”abc”;
int len=strlen(str);
//int count[len]; compiling error
Int* count=(int*) malloc(len*sizeof(int));
Pass a 2d array as parameter, you should specify the 2nd dimension’s size like a[][5]
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment