Created
March 16, 2018 09:29
-
-
Save rambo/3c4b98a9e37c068f9edeb5d53cc08eba to your computer and use it in GitHub Desktop.
reminder to self on how to deref void pointer to integer
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
// gcc -Wall void_ptr.c -o void_ptr ; ./void_ptr | |
#include <stdio.h> | |
#include <stdint.h> | |
void muck_count(void* param) | |
{ | |
uint8_t *foo = (uint8_t*)param; | |
printf("foo %u\n", *foo); | |
*foo = 0; | |
} | |
int main() | |
{ | |
uint8_t count = 0; | |
count = 10; | |
printf("Count before %u\n", count); | |
muck_count(&count); | |
printf("Count after %u\n", count); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment