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
nasm -f elf64 example.asm -o example.o
gcc -no-pie -m64 example.o -o example
and then run
./example
./example
it runs good and print:
enter a number:
enter a number:
but then crashes and prints:
Segmentation fault (core dumped)
Segmentation fault (core dumped)
That means printf works just fine but scanf is not . What am I doing wrong with scanf then?
attachment 0
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....
Jump to solution
2 Replies
Solution
Joseph Ogbonna
Joseph Ogbonna4mo ago
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.
Marvee Amasi
Marvee Amasi4mo ago
Thank you @Joseph Ogbonna
Want results from more Discord servers?
Add your server