Let $f:[0,1]\to\mathbb{R}$ be a nonconstant continuous function. Is $S=\{x: f(x)=0\}$ finite?
I have thought of a function with countably many $0$'s like lots of triangular bumps at each point $\{1/n\}$, I mean lots of $W/M$ shapes on $[0,1]$. Is it okay?
Your suggestion will work well. If you want an explicit formula, look at $f(x)=x\sin(1/x)$ when $x\ne 0$, and $f(0)=0$.