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

Bug in BubbleSort.c #396

Open
ashwek opened this issue Nov 16, 2018 · 0 comments
Open

Bug in BubbleSort.c #396

ashwek opened this issue Nov 16, 2018 · 0 comments

Comments

@ashwek
Copy link
Member

ashwek commented Nov 16, 2018

Describe the bug
in Sorting/Bubble Sort/C/BubbleSort.c
int arr[] = {6, 4, 5, 8, 2, 1, 9};
int n = sizeof(arr)/sizeof(arr[0]);
scanf("%d",&n); <<---
bubbleSort(arr, n);

taking input of n is not a good idea (unless user inputs the elements in the array too). If user enter a large value (larger than the actual size of array) program would print junk values and for sufficiently large value it can also crash the program.

To Reproduce
Steps to reproduce the behavior:

  1. input any large value (larger than the actual size of the array)

Screenshots
Output Screenshot

arnejasaksham added a commit to arnejasaksham/codezilla that referenced this issue Oct 12, 2019
Removed input scanning.
@arnejasaksham arnejasaksham mentioned this issue Oct 12, 2019
7 tasks
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