SparkNotes Shopping Cart  |     |  Checkout
Brought to you by Barnes and Noble
Why Use Pointers?
  
 
Problems
Problem 2.1: Write a function that takes pointers to two integers and swaps the values stored at those addresses. [Solution]
Problem 2.2: Why doesn't this function swap the values correctly?
void swap(int a, int b)
{
	int temp = a;
	a = b;
	b = temp;
}
[Solution]
Problem 2.3: Write a function which takes an array of 5 integers and sets all the values to 0. [Solution]
Problem 2.4: Write a function void set_to_NULL(char **ptr); which takes a pointer to a pointer to a character and sets the memory at that address to NULL. [Solution]
Problem 2.5: CHALLENGE: Write a swap function that doesn't use a temporary variable for storage. Hint: use the XOR operator. Are there any cases in which this won't work? [Solution]
Help | Feedback | Make a request | Report an error | Send to a friend
 
Learn Calculus in a flash! You’ll be amazed at how easy it is with Calculus Study Cards.
More...
 
You'll flip over our Pre-Algebra Study Cards—writing out flashcards is now a thing of the past.
More...
 
 
Go to top