Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wassim31 opened this issue Aug 2, 2021 · 0 comments
Open

Comments

@wassim31
Copy link

wassim31 commented Aug 2, 2021

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 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant