A search for supersymmetric partners of top quarks decaying as $\tilde{t}_1\to c\tilde\chi^0_1$ and supersymmetric partners of charm quarks decaying as $\tilde{c}_1\to c\tilde\chi^0_1$, where $\tilde\chi^0_1$ is the lightest neutralino, is presented. The search uses 36.1 ${\rm fb}^{-1}$ $pp$ collision data at a centre-of-mass energy of 13 TeV collected by the ATLAS experiment at the Large Hadron Collider and is performed in final states with jets identified as containing charm hadrons. Assuming a 100% branching ratio to $c\tilde\chi^0_1$, top and charm squarks with masses up to 850 GeV are excluded at 95% confidence level for a massless lightest neutralino. For $m_{\tilde{t}_1,\tilde{c}_1}-m_{\tilde\chi^0_1}