Strings from domain walls in supersymmetric Yang-Mills theory and adjoint QCD