Carbon has a normal valence of four, and it has four bonds here. There are no formal charges on the hydrogens either.
Carbon monoxide has a structure that is very similar to formaldehyde. With ten electrons total, the only way to get an octet on both atoms is to make three bonds between carbon and oxygen.
New chemical bonds are formed by sharing electrons.
Old chemical bonds are broken when one atom takes the bonding electrons away from another atom.
If an atom donates fewer electrons than normal and everyone still has an octet, it must be getting extra electrons from somewhere else. O) is a chemical that is used to preserve tissues; you may be familiar with its odour from anatomy lab.
Carbon monoxide results from burning fossil fuels; it is also an important industrial chemical used in manufacturing detergents. Calcium carbonate is found in limestone and chalk, for instance. Oxygen has a normal valence of two, and it has two bonds in formaldehyde, so there is no formal charge on the oxygen.
These charges cancel to give an overall neutral molecule.
What we are really doing when we assign formal charge is comparing how many electrons the atom brought with it from the periodic table to how many it has now.
Oxygen has normal valence two, but here it is making three bonds.
It is sharing an extra pair of its electrons with carbon to make that third bond.