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

前端 未结 8 778
感动是毒
感动是毒 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:48

    It should look something like this:

    unsigned long address=0x80; 
    
    void (*func_ptr)(void) = (void (*)(void))address;
    func_ptr();
    

    However, it is not a very safe operation, jumping to some unknown address will probably result in a crash!

提交回复
热议问题