How does this code work?
#include <stdio.h> #include <stdlib.h> #include <string.h> sc[] = bla bla bla a bunch of hex; int main(void) { (*(void(*)()) sc)(); }
This is (*(void(*)()) sc)(); in particular, I'm not sure.
(*(void(*)()) sc)();
Sc [] is an array of machine instructions, each byte is described in hexadecimal format.
The line in main interprets sc as a pointer to a function that takes no arguments and returns void, and calls the function.
SC is passed as a pointer to a function, and then called. This means that the code in SC [] is actually machine instructions (encoded in hexadecimal format).
Passes sc to *(void(*)() , which is a pointer to a function that returns a void, and does not accept any parameters, and calls the function.
sc
*(void(*)()