I understand that this error has to do with how much memory my program tries to use when I run it, but I'm new to C and I don't quite have a handle on memory management yet. If anyone wants to take the time to tell me where in my code this is occurring I would very much appreciate it.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
char * getRandomHex(int length, char * result) {
char hexCharacters[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
for (int i = 0; i < length; i++) {
char randChar = hexCharacters[rand()%16];
strncat(result, &randChar, 1);
}
return result;
}
int main() {
for (int i = 0; i < 10; i++) {
char * result;
result = getRandomHex(6, result);
printf("%s", result);
printf("\n");
}
}