Algorithms icon indicating copy to clipboard operation
Algorithms copied to clipboard

in Insertion-sort.c : the user can access to other blocks of memory

Open wassim31 opened this issue 2 years ago • 0 comments

int n, array[1000], c, d, t; printf("Enter number of elements\n"); scanf("%d", &n);

the compiler is allocating 4000 bytes in the stack , then the program asks the user how many elements he wants.. instead of that , it's better to ask the user how many elements he wants first ( upper-bounded ) , do dynamic memory allocation on the heap segement using standard library function void * malloc( size_t memorySize );

wassim31 avatar Aug 02 '21 16:08 wassim31