Created
March 25, 2023 19:17
-
-
Save emandret/c36331ba4afde0caee9f9d7da43a4237 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#pragma pack(1) | |
struct my_struct | |
{ | |
unsigned char b0; | |
unsigned char b1; | |
unsigned char b2; | |
unsigned char b3; | |
unsigned char b4; | |
}; | |
int main(void) | |
{ | |
struct my_struct *ptr; | |
unsigned char buffer[5]; | |
ptr = (struct my_struct *) buffer; | |
ptr->b0 = 'h'; | |
ptr->b1 = 'e'; | |
ptr->b2 = 'l'; | |
ptr->b3 = 'l'; | |
ptr->b4 = 'o'; | |
for (int i = 0; i < 5; i++) | |
{ | |
putchar(buffer[i]); // Print "hello" | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment