An 8-year-old boy was attacked by a shark while swimming off the North Carolina coast on Sunday afternoon, officials said.