start of stringsort, just basic array for now.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -10,7 +11,7 @@ void numberprinter(int inarr[], int arrlength) {
|
||||
|
||||
struct Darray {
|
||||
int *digits;
|
||||
int length;
|
||||
size_t length; // blijkbaar correcte eenheid voor length, malloc stuff ofzo (instead of hardcoding it)
|
||||
};
|
||||
|
||||
struct Darray *numbertodigitDarr(int input) {
|
||||
@@ -25,7 +26,7 @@ struct Darray *numbertodigitDarr(int input) {
|
||||
|
||||
// allocate memory for struct and array, apparently more ideomatic to have a single malloc
|
||||
struct Darray *DigDarr =
|
||||
malloc(op * sizeof(int) + sizeof(*DigDarr) + sizeof(int));
|
||||
malloc(op * sizeof(int) + sizeof(*DigDarr) + sizeof(int));
|
||||
if (DigDarr == NULL) {
|
||||
printf("allocation failed");
|
||||
exit(0);
|
||||
@@ -90,4 +91,4 @@ iterator (which has to start from 0, because we don't know the size of the
|
||||
number?) then our number will be the wrong way around.
|
||||
|
||||
malloc, blijkbaar very different
|
||||
*/
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user