Spivak Calculus on Manifolds - Problem 2.26 (d) 
Problem 2.26 - d) If $A \subset \mathbb{R}^n$ is open and $C \subset A$ is compact, show that there is a non-negative $C^{\infty}$ function $f: A \longrightarrow \mathbb{R}$ such that $f(x) > 0$ for $x \in C$ and $f = 0$ outside of some closed set contained in $A$.

This is what I think at the moment:

$A$ is open, so there is $\delta_x > 0$ for each $x \in A$ such that $B(x,\delta_x) \subset A$, then $\{ B(x,\delta_x) \ ; \ x \in A \}$ is an open cover for $C$ and there is a finite subcollection $\{ B(x_i,\delta_{x_i}) \ ; \ i = 1, \cdots, n \}$ that covers $C$ by the compactness of $C$. Analogously, we obtain a finite subcollection $\{ B(x_i,\delta_{x_i}/2) \ ; \ i = 1, \cdots, n \}$ that covers $C$ by the compactness of $C$, so the set $D := \bigcup_{i=1}^{i=n} \overline{B(x_i,\delta_{x_i}/2)} \subset A$. I would like to define $f:A \longrightarrow \mathbb{R}$ such that $f(x) > 0$ for $x \in C$ and $f = 0$ for $x \in A - D$.

I would like to know if I'm the right way and to receive a hint about how construct this function. Thanks in advance!
 A: You may construct your closed set, i.e. $D$, at the start, but ultimately the proof comes down to (a) $C$ is compact and (b) is contained in an open set. We summarize the proof to three parts. 
(i) If $x = (x_1, \ldots, x_n) \in C$, then $x \in U_1 \times \cdots U_n \subseteq A$, since $A$ is open, where $U_i$ are open intervals. This is by definition of product topology of $\mathbb{R}^n$. By taking subsets, $U_i$ are bounded intervals. 
(ii) Use compactness to obtain a finite collection of open rectangles, $\{R_i \}$. We may define functions $g_i: \mathbb{R}^n \rightarrow \mathbb{R}$ such that $g_i \in C^{\infty}$ is positive on $R_i$ and $0$ elsewhere. Take the sum of all $g_i$. 
(iii) Existence of a closed set: We can either replace step (i) with $A = \mathring{D}$ (your strategy), OR, choose sufficiently small open intervals in (i) such that $\bigcup_{ i=1}^n \overline{R_i}$ is contained in $A$. 
A: $\newcommand{\Reals}{\mathbf{R}}$Here's a sketch based on rectangles instead of balls, for which the functions may be easier to construct:
If $x = (x_{1}, \dots, x_{n}) \in \Reals^{n}$ and if $\delta > 0$, let
$$
R(x, \delta) = [x_{1} - \delta, x_{1} + \delta] \times \cdots \times [x_{n} - \delta, x_{n} + \delta]
$$
be the axis-oriented cube of "radius" $\delta$ centered at $x$.
For each point $x$ and each $\delta > 0$, consider the "apparatus" $R(x, \delta/2) \subset R(x, \delta)$. It's straightforward to show that there exists a smooth, non-negative function $f_{x}$ that is identically $1$ on $R(x, \delta/2)$ and identically $0$ outside $R(x, \delta)$. (Define such a function in one dimension, then take the obvious product of one-variable functions.)
Now, for each $x$ in $C$, choose an apparatus such that the large box $R(x, \delta) \subset A$, then use compactness of $C$ together with the fact that the small boxes cover $C$ to pick finitely many apparatuses whose small boxes cover $C$. The sum of the corresponding functions $f_{x}$ is smooth, non-negative, positive on $C$, and identically $0$ outside $A$.
