There isn't such a function. If $f$ is nonzero and continuous at some point $x$, then there is a neighbourhood of $x$ on which $f$ doesn't vanish. Hence if the set of zeros of $f$ is dense, then the function has to be discontinuous at every value on which it doesn't vanish.