PhotoArt web site

Some selected photographs rearranged in my new photo blog.
Take a look!

Posted at 10am on 28/06/08 | no comments | Filed Under: Fotografia read on

const pointer vs. pointer to const


/*
ex. usage of a constant pointer to a (variable integer)
ex. how to fuck a pointer to a constant variable

*/
#include

int main(void)
{
const int c=0;
// constant pointer to a (variable) integer: can change the value of the var but not the pointer
int* const ptr1 = malloc(sizeof(int));
*ptr1 = 10;
*ptr1 = 100;

int t;
// pointer to a constant integer: can change the pointer but not the variable
const int* ptr2 = malloc (sizeof(int));
int modvar = 10;

ptr2 = &modvar;
modvar = 100;

printf(”%d\n”,

Posted at 10pm on 27/06/08 | no comments | Filed Under: Computer Science read on