You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
809 B
C

#include <stdio.h>
#define DOLLARS 0x24;
// Example of function declaration. This is what the preprocessor does with the header files
void set_to_y(char *p);
int main()
{
char my_char = 'a';
char *p_char;
p_char = &my_char;
printf("The value of *p_char is set to %c\n", *p_char);
set_to_y(p_char);
printf("Lets check the value of my_char: %c\n", my_char);
printf("You, know what I want to just muck with your memory directly\n");
//derefence the location and just set the byte we want
*p_char = DOLLARS;
printf("So all your bits now should show my_char as $ DOLLARS. Lets see: %c\n", my_char);
return 0;
}
// This is function definition
void set_to_y(char *p)
{
fprintf(stdout, "Setting the value at address %p from %c to y\n", &p, *p);
*p = 'y';
}