What am I doing wrong with "scanf" ?

When I compiled my actuat_so assembly file's code using
 nasm -f elf64 example.asm -o example.o
gcc -no-pie -m64 example.o -o example

and then run
 ./example

it runs good and print:
enter a number: 
but then crashes and prints:
 Segmentation fault (core dumped)

That means printf works just fine but scanf is not . What am I doing wrong with scanf then?
file0.jpg
Solution
Troubleshooting Steps:

1) Verify that scanf is linked correctly and the assembly code matches the calling convention.
2) Ensure that you are aligning the stack properly before calling scanf.
3) Check if printf or other functions in your code are causing issues indirectly.
Was this page helpful?