Nothing is foolproof, but here are some tips.
2. Dispose of uneaten scraps outside of campsite
3. Keep uneaten food outside of campsite (hung in a stuff-sac from a tree)
4. If you really want to be careful, cook on a fire away from your sleeping area (I don't do this).
This won't necessarily keep out annoying critters, like skunks and raccoons, especially if you are camping at a popular campground. Many people leave stuff out, and the animals are used to people.