Defect formation and magnetic properties of carbon-doped ZnO nanowires by the first principles