Answer the question
In order to leave comments, you need to log in
Why does the "Segmentation Fault" pop up?
I look in the direction of mastering C (the first day). I decided to write a password generator utility.
By tradition, I opened Google and go: https://github.com/yarkovaleksei/passgen
It compiles fine:
$ make
gcc -c ./source/passgen.c
gcc -c ./source/main.c
gcc -o ./bin/passgen passgen.o main.o
Ошибка сегментирования
$ ./bin/passgen -l 25
Ошибка сегментирования
Answer the question
In order to leave comments, you need to log in
Well, that's right, that's how it should be. SIGSEGV occurs when a program tries to modify data in a region that does not belong to it, that is, not in a static buffer and not in a dynamic region obtained through malloc ().
will create a variable containing a pointer to the sign. The variable is not initialized, so it contains garbage. If this garbage is interpreted as a write address, what is done here:
SIGSEGV is guaranteed :D
Deal with pointers and memory allocation, what do you think you returned here: return result ?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question