Electrons are transferred from one atom to another (this is in an effort to either fill or empty the outer shell to become stable.) An atom has no charge because the electrons and protons have equal and opposite charges. But an ion will have a charge: an electron has a charge of -1, so loosing an electron looses one negative charge, making the ion +1. So gaining one electron will make an atom a -1, gaining two will make it -2.
The atoms the gain or loose electrons to each other will have opposite charges: for example if a gives away 1 atom and b gains it, a is +1 and b is -1. These charges mean that the ions are attracted to each other (ionic bond), so they form an ionic compound.