How to jump the program execution to a specific address in C?

前端 未结 8 784
感动是毒
感动是毒 2021-01-02 01:17

I want the program to jump to a specific address in memory and continue execution from that address. I thought about using goto but I don\'t have a label rather

8条回答
  •  没有蜡笔的小新
    2021-01-02 01:44

    Do you have control of the code at the address that you intend to jump to? Is this C or C++?

    I hesitantly suggest setjmp() / longjmp() if you're using C and can run setjmp() where you need to jump back to. That being said, you've got to be VERY careful with these.

    As for C++, see the following discussion about longjmp() shortcutting exception handling and destructors destructors. This would make me even more hesitant to suggest it's use in C++.

    C++: Safe to use longjmp and setjmp?

提交回复
热议问题