Cardinality of $A=\{f: \mathbb R \to \mathbb R , f \text{ is continuous and} f(\mathbb Q) \subset \mathbb Q\}$

Find the cardinality of the set $A=\{f: \mathbb R \to \mathbb R , f \text{ is continuous and} f(\mathbb Q) \subset \mathbb Q\}$.

My attempt at a solution:

First I've noticed that $A \subset B=\{f:\mathbb R \to \mathbb R, f \space \text{is continuous}\}$. Since a continuous functions is determined by which values it takes at all the rational points of the domain, it's easy to see that $|B|=c^{\aleph_0}=c$. Now, I am trying to find a subset $C$ of $A$ such that $|C|=c$ but I am having a hard time finding this subset. Could anyone give me suggestions/hints to find this subset?

-

For $C$, you can restrict to functions $f$ that are continuous and piecewise linear, each piece having rational slope and points with integer coordinates as endpoints, and such that $f(\mathbb Z)\subseteq\{0,1\}$. Do you see how to proceed?

-
As $f$ is determined by which values takes at the integers, then it's clear that $|C|=2^{\aleph_0}=c$. I think I can prove that $f(\mathbb Q) \subset \mathbb Q$: pick a rational point $q$, and integers $z_1$, $z_2$: $z_1<q<z_2$. Then, $f$ is $f(x)=(x-z_1)\dfrac{f(z_2)-f(z_1)}{z_2-z_1}+f(z_2$) for all $x \in [z_1,z_2]$, $f(q)=(q-z_1))\dfrac{f(z_2)-f(z_1)}{z_2-z_1}+f(z_2)$, and by closure of addition and multiplication of $\mathbb Q$, $f(q) \in \mathbb Q$. I am not so sure how to formally prove $f$ is continuous (I know this is obvious if I draw the graph of the function). Thanks for the answer. – user100106 Dec 6 '13 at 2:25
For continuity of piecewise defined functions: If $g,h$ are continuous functions, and we have that $f(x)=g(x)$ if $x\le a$, $f(x)=h(x)$ if $x>a$, and $h(a)=g(a)$, then $f$ is continuous. So you just have to apply this result around each integer. – Andrés Caicedo Dec 6 '13 at 2:29
Thanks for the help! – user100106 Dec 6 '13 at 2:33
You are welcome! – Andrés Caicedo Dec 6 '13 at 2:33

Hint: Let the values of $f$ at integers be a sequence of rationals converging to your favorite real number. Extend by line segments in between.

-
Thanks for the answer but I don't quiet get how to define this function. You say that $f$ at the integers is a sequence of rationals converging to $r \in \mathbb R$. Sorry if I am asking something stupid, but what do you mean by this? For example, I pick $z \in \mathbb Z$ and what is $f(z)$? – user100106 Dec 6 '13 at 2:31
Let's say you like the real number $\pi$. Then you could let $f(n) = 0$ for $n\leq 0$, $f(1) = 3$, $f(2) = 3.1$, $f(3) = 3.14$, $f(4) = 3.141$, and so on - the values are a sequence converging to $\pi$ (of course there are others, but we can just pick one such sequence). – universalset Dec 6 '13 at 2:36
The idea is that we thus have (at least) one such function which corresponds to each real number. – universalset Dec 6 '13 at 2:37
Now I got it, thanks! – user100106 Dec 6 '13 at 2:55