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!