How does gluing work? If one "glues" together a cylinder $C$ with a cylinder $C'$ the resulting space should be a torus as a subspace of $\mathbb R^3$. Both $C$ and $C'$ are $S^1 \times [0,1]$. If I understand it correctly the identification requires two maps $f: C \to \mathbb R^3$ and $g: C' \to \mathbb R^3$ with the property that $f(x)=g(x) \in S^1 \subseteq \mathbb R^3$ on $S^1 \times \{0\}$ and $f(x)=g(x) \in S^1 \subseteq \mathbb R^3$ on $S^1 \times \{1\}$ such that $f,g$ are continuous and one-to-one.
What I'm struggling with is how to define $f$ and $g$. I tried as follows: My idea is to define $f$ and $g$ such that they are inclusion maps into the torus at the origin of $\mathbb R^3$. The torus can be parameterized as $x = \cos(s)(R+r\cos(t))$, $y=\sin(s)(R+r\cos(t))$, $z=r\sin(t)$ for $s,t \in [0,2\pi)$.
For a point $(x,y)$ on $C$ how to define $f:C \to \mathbb R^3$? I can not do it. Thank you for any help!!

Instead of $(x,y)$, let's write $(\cos(\theta), \sin(\theta), \phi)$.  Then $f$ should send this to $(\cos(\theta)(R + r\cos(\pi\phi)),\sin(\theta)(R + r\cos(\pi\phi)),r\sin(\pi\phi))$.  Thus, the $\theta$ coordinate is sent to the $s$ coordinate, and the $\phi$ coordinate is sent to the first $[0,\pi]$ of the $t$ coordinate.  $g$ should do likewise, but covering the $[\pi,2\pi]$ of the $t$ coordinate.
Be warned that, especially in algebraic topology, these kinds of explicit constructions tend not to be very useful.  We typically only care about things like the torus as topological spaces; the specific embedding of the torus in Euclidean space is usually irrelevant.
If you continue to study topology, you'll probably see gluings like this treated more abstractly, in arguments like the following.  Both cylinders are product spaces $S^1 \times [0,1]$, and the gluing ignores the $S^1$ coordinate.  Thus, the glued space should be $S^1$ times the space you get by gluing two intervals along their endpoints -- that is, it's $S^1 \times S^1$, a torus.
Note that you can do this sort of gluing construction as a quotient of the disjoint union of the spaces involved.  This might be easier than coming up with the target first and then trying to define the maps into it.
