summaryrefslogtreecommitdiffstats
path: root/04_exercise/quicksort.c
diff options
context:
space:
mode:
Diffstat (limited to '04_exercise/quicksort.c')
-rw-r--r--04_exercise/quicksort.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/04_exercise/quicksort.c b/04_exercise/quicksort.c
index 88a47a2..f912f2b 100644
--- a/04_exercise/quicksort.c
+++ b/04_exercise/quicksort.c
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+#include <string.h>
static size_t partition(int v[], size_t len);
@@ -87,9 +88,9 @@ int main(int argc, const char *argv[]) {
/* read the length of the list from the command line */
size_t list_len = 30000000;
if (argc >= 2) {
- long arg = atol(argv[1]);
+ long arg = strtol(argv[1], (char **)&argv[strlen(argv[1])], 10);
if (arg > 0)
- list_len = arg;
+ list_len = (size_t)arg;
}
/* generate a list with random integers */