|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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]
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contact Us | Privacy Policy | Terms and Conditions | About
©2006 SparkNotes LLC, All Rights Reserved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||