Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seeking explanation of convoluted C expression: (*(void(*)())sc)() [closed]

Tags:

c

syntax

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 (*(void(*)()) sc)(); specifically is what I'm unsure of.

like image 207
user793663 Avatar asked Dec 17 '22 13:12

user793663


1 Answers

Sc[] is an array of machine instructions, with each byte described in hexadecimal.

The line in main interprets sc as a pointer to a function that takes no arguments and returns a void, and calls the function.

like image 130
Sherm Pendley Avatar answered May 15 '23 18:05

Sherm Pendley