Home > SparkNotes > Computer Science Study Guides > What Are Pointers? >

sparknotes

What Are Pointers?


Problems

Problem : Is the following piece of C code valid?


int main()
{
	int *steve;
	steve = &steve;
	return 0;
}


Problem : What is wrong with the following code?


int main()
{
	int *steve;
	*steve = 100;
	printf("%d\n", *steve);
	return 0;
}


Problem : Will the following code compile and run?


int main()
{
	int a = 5;
	a = *&*&*&*&a;
	printf("a is %d\n", a);
	return 0;
}


Problem : Will the following code compile and run?


int main()
{
	int a = 5;
	a = **&&a;
	printf("a is %d\n", a);
	return 0;
}


Problem : Why do we care about assigning the value NULL to a pointer when the pointer isn't being used?