A search for supersymmetric partners of top quarks decaying as t ~ 1 → c χ ~ 1 0 and supersymmetric partners of charm quarks decaying as c ~ 1 → c χ ~ 1 0, where χ ~ 1 0 is the lightest neutralino, is presented. The search uses 36.1 fb⁻¹ of 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 χ ~ 1 0, top and charm squarks with masses up to 850 GeV are excluded at 95% confidence level for a massless lightest neutralino. For m t ~ 1, c ~ 1 − m χ ~ 10 <100 GeV, top and charm squark masses up to 500 GeV are excluded.