Just to add an illustration to the above info, here are end differences in the cables (note, don't pay too much attention to the cable lengths shown in the bottom right. Most likely the cable you buy will be sufficiently long and you just cut to fit). You can get road or mountain specific brake cables, or you can buy universal brake cable that has the road (mushroom) and the mountain (barrel) configuration on each end and you cut off what you don't need.