The confinement of a superconductor in a thin film changes its Fermi-level density of states and is expected to change its critical temperature $T_c$. Previous calculations have reported large discontinuities of $T_c$ when the chemical potential coincides with a subband edge. By solving the BCS gap equation exactly, we show that such discontinuities are artifacts and that $T_c$ is a continuous function of the film thickness. We also find that $T_c$ is reduced in thin films compared with the bulk if the confinement potential is lower than a critical value, while for stronger confinement $T_c$ increases with decreasing film thickness, reaches a maximum, and eventually drops to zero. Our numerical results are supported by several exact solutions. We finally interpret experimental data for ultrathin lead thin films in terms of a thickness-dependent effective mass.