Prove that $g(x)=0$ for all $x$ in $\mathbb{R}$ 
Suppose that the function $g:\mathbb{R}\rightarrow\mathbb{R}$ is continuous and that $g(x)=0$ if $x$ is rational. Prove that $g(x)=0$ for all $x$ in $\mathbb{R}$.


Proof:
Let $\{x_n\}$ be a sequence of $\mathbb{Q}$, then the limit of $\{x_n\}$ is in $\mathbb{Q}$ and $\lim\limits_{n\rightarrow\infty}f(x_n)=f(x)=0$ where $x\in\mathbb{Q}$. And by that fact that $\mathbb{Q}$ is dense of $\mathbb{R}$, so the limit of $\{x_n\}$ is in $\mathbb{R}$. Thus, since the function $g:\mathbb{R}\rightarrow\mathbb{R}$ is continuous, we can conclude that $g(x)=0,\forall x\in\mathbb{R}$.

It seems I just put everything into my proof to convince me that is right. Can anyone check my solution? Thanks
 A: As fleablood pointed out, your argument as it is now is flawed. 
I would like to suggest a point-set-topology way to prove the extension proposition, which may be cleaner in nature: we prove (1) if $f,g: \mathbb{R} \to \mathbb{R}$ are continuous, then the set $S$ of all $x \in \mathbb{R}$ such that $f(x)=g(x)$ is closed in $\mathbb{R}$; (2) with $f := 0$ and $f = g$ on $\mathbb{Q}$, the set $\mathbb{Q}$ is dense in $\mathbb{R}$ and $S \supset \mathbb{Q}$ only if $f=g$ on $\mathbb{R}$.
To prove (1), it suffices to prove that $\mathbb{R}\setminus S$ is open in $\mathbb{R}$. Let $a \in \mathbb{R} \setminus S$; then $f(a) \neq g(a)$ by assumption; let $d := |f(a) - g(a)|$. By continuity assumption, there is some open ball $V^{a}$ of center $a$ such that $x \in V^{a}$ only if 
$
|f(x) - f(a)|, |g(x)-g(a)| < d/2;
$
if there is some $x \in V^{a}$ such that $f(x) = g(x)$, then by triangle inequality we have 
$$
|f(a) - g(a)| \leq |f(x)-f(a)| + |f(x) - g(x)| + |g(x) - g(a)| < d,
$$ 
a contradiction; hence $x \in V^{a}$ only if $f(x) \neq g(x)$, and we have proved (1). Now (2) follows immediately as indicated above.
