From 3ed754312c38ad1ffc9b569062f0fdc0b471a4be Mon Sep 17 00:00:00 2001 From: Anup Kumar Panwar <1anuppanwar@gmail.com> Date: Sat, 25 Nov 2017 14:28:25 +0530 Subject: [PATCH] Update HeapSort.c --- Sorts/HeapSort.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Sorts/HeapSort.c b/Sorts/HeapSort.c index 80ced37a..0010091a 100644 --- a/Sorts/HeapSort.c +++ b/Sorts/HeapSort.c @@ -6,7 +6,6 @@ void heap_sort(int *unsorted, int n); int main() { int n = 0; int i = 0; - char s[50]; char oper; int* unsorted; @@ -15,13 +14,9 @@ int main() { unsorted = (int*)malloc(sizeof(int) * n); while (getchar() != '\n'); printf("Enter numbers separated by a comma:\n"); - gets(s); - - char *ptr = strtok(s, ","); - while (ptr != NULL && i < n) { - *(unsorted + i) = atoi(ptr); + while (i != n) { + scanf("%d,", (unsorted + i)); i++; - ptr = strtok(NULL, ","); } heap_sort(unsorted, n);