My book says that each subgroup of $\mathbb Z/n\mathbb Z$ is of the form $$ H=\{\overline d,\overline{2d},\dots,\overline{n-d},\overline n\}, $$ where $d$ is a divisor of $n$. However, I don’t see what goes wrong if $p\nmid n$, and if we take $$ H'=\{\overline p,\overline{2p},\dots,\overline{np}\}. $$ It seems to me we still have a subgroup, because $\overline 0$ is an element, for $\overline{pn}=\overline 0$. Also, if $\overline a, \overline b\in H'$, we can write $a=kp$ and $b=lp$, and then $\overline a +\overline b=\overline{(k+l)p}\in H'$. Same for the inverse. So what am I missing here? Maybe it isn't guaranteed that $\overline{(k+l)p}\in H'$?
EDIT
By the help of the chat, I realised that obviously $H'$ has $n$ elements, and therefore it must equal $\mathbb Z/n\mathbb Z$.
What your book asserts is not that a generator of a subgroup is necessarily a divisor of $n$, but that, among its generators, there is a divisor of $n$.
Actually, one can easily show that the subgroup $\langle \bar p\rangle\subset \mathbf Z/n\mathbf Z$ is also generated by (the congruence class of) $\gcd(p,n)$.
For instance, in $\mathbf Z/12\mathbf Z$, the elements $\bar 1, \bar 5,\bar 7,\overline{11}$ generate the whole group; $\bar 2$ and $\overline{10}$ generate the same subgroup, as $\bar 3$ and $\bar 9$, $\;\bar 4$ and $\bar 8$.