Here's a semi-explicit construction for a smooth function f that is zero precisely on the classical Cantor set. By this set I mean the one that is obtained from I_0 = [0,1]$I_0 = [0,1]$ by repeatedly removing the middle third of any ensuing interval. So let's denote by I_n$I_n$ the n$n$-th set in this process.
Now let's make a smooth function f_n$f_n$ on [0,1]$[0,1]$ such that its zero set is exactly I_n$I_n$. Starting with f_0 = 0$f_0 = 0$ we obtain f_{n+1}$f_{n+1}$ from f_n$f_n$ as follows:
set f_{n+1} = f_nSet $f_{n+1} = f_n$ on I_{n+1}$I_{n+1}$ and on an interval that is removed from I_n$I_n$ make f_{n+1}$f_{n+1}$ equal to a bump function that is 0 only at the boundary of the interval. We can choose the bump function to be of height 2^{-2^n}$2^{-2^n}$.
This choice of heights of the bump functions will ensure that the derivatives of f$f$ all converge uniformly to their pointwise limits. Hence the limit function f_n$f_n$ is again smooth. By construction its zero set is exactly the Cantor set.