Let S={0}∪{1/n:n≥1} and let D be the Dirichlet function, equal to 1 on rationals and 0 on irrationals. Then f(x)=d(x,S)D(x) is continuous exactly on S: the distance factor squeezes it to zero on S, while away from S it is a positive continuous factor times an everywhere-discontinuous function.