why is the program crashing when I change 3000 to 4000 on this line
char arrFilename[3000][MAX_PATH + 1];
Code:
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <time.h>
main()
{
int i,j;
char path[100] = "c:\\temp";
// crashes at 4000????
char arrFilename[3000][MAX_PATH + 1];
DIR *dir;
struct dirent *ent;
dir = opendir(path);
if (dir != NULL){
j = 0;
while((ent = readdir (dir)) != NULL) {
//printf("j = %d fname: %s\n",j,ent->d_name) ;
//copy string to array
strcpy(arrFilename[j],ent->d_name);
j++;
}
closedir (dir);
} else {
/* could not open directory */
perror (path);
//return EXIT_FAILURE;
}
// print array of filenames
for (i = 0; i < j; ++i) {
printf("i %d: %s\n",i, arrFilename[i]);
}
}