$ make
gcc -c ./source/passgen.c
gcc -c ./source/main.c
gcc -o ./bin/passgen passgen.o main.o
Ошибка сегментирования
$ ./bin/passgen -l 25
Ошибка сегментирования
char* result;
result[counter] = randChar;
char* generate_password(char *symbols, int length)
{
srandom(time(NULL));
int counter = 0;
char randChar;
char *result = malloc(length + 1); // FIX
if(length < 1) {
printf("Type in a password Length \n");
scanf("%d", &length);
}
while(counter < length)
{
randChar = symbols[random () % strlen(symbols)];
result[counter] = randChar;
counter++;
}
return result;
}