Azimuthal correlations of prompt D mesons with charged particles in pp and p–Pb collisions at √sNN=5.02TeV