TITLE: Can there be two distinct, continuous functions that are equal at all rationals?
QUESTION [64 upvotes]: Akhil showed that the Cardinality of set of real continuous functions is the same as the continuum, using as a step the observation that continuous functions that agree at rational points must agree everywhere, since the rationals are dense in the reals.
This isn't an obvious step, so why is it true?

REPLY [5 votes]: Sketch of an alternative proof.
First, recall (or see for the first time) the following fact:
Given a continuous function $h: \mathbb{R} \rightarrow \mathbb{R}$, the set $K_h := \{x \in \mathbb{R}: h(x) = 0\}$ is closed.
"Recalling" this fact might seem just like sweeping details under the rug; indeed, it is Exercise $4.3.7$ in Stephen Abbott's introductory textbook Understanding Analysis.
Nevertheless, one can then proceed as follows:
Let $f, g: \mathbb{R} \rightarrow \mathbb{R}$ be continuous, real-valued functions that agree on $\mathbb{Q}$.
Furthermore, let $h = f - g$. Then $h$ is the difference of continuous functions, hence continuous itself; we can now use the fact above to conclude that $\mathbb{Q} \subset K_h \subset \mathbb{R}$.
In particular, $K_h$ is a closed set of real numbers that contains $\mathbb{Q}$.
We are given that the rationals are dense in the reals, i.e., $cl(\mathbb{Q}) = \mathbb{R}$.
Therefore, $K_h = \mathbb{R}$, which means that for all $x \in \mathbb{R}$, we have $h(x) = 0$.
By the definition of $h$, this means for all $x \in \mathbb{R}$ we have $f(x) - g(x) = 0$, i.e., $f(x) = g(x)$.
This "proves" the desired result. QED
N.B.  The problem posed here is also in Abbott's text: it is Exercise $4.3.8(b)$.