A calorie, by definition is a unit of energy-producing potential equal to the amount of heat that is contained in food and released upon oxidation by the body. To put it in simple terms, calories provide energy for life processes. Both protein and carbohydrates contain 4 calories per gram, and fat contains 9. As you can see, fat is the most calorie dense of the concerned nutrients. To find out how many calories is enough for you to gain muscle, take your bodyweight and multiply it by 24, but make sure you have a correct balance of macro-nutrients so you don't gain too much excess fat.
To keep your body in an anabolic (muscle building) state makes sure to eat every 2-3 hours. This can be pretty hard, but if you are dedicated to the cause of success you will make time for your meal even if it means pre-packaging them
Eating for Specific Purposes, Pre and Post Workout:
Post-workout is the most important meal of the day to the body builder, pre-workout coming in 2nd. After a workout, your body's energy stores have been used up, and your body needs protein a.s.a.p. You need both fast acting energy and fast acting protein. The answer, simple carbs and whey protein. In order to fuel the muscle building process effectively, I recommend keeping a protein-carb ratio of 1-3, personally I take my serving of meal replacement powder and on top of that an 8oz. glass of o.j. (fast acting simple carbohydrates). Now for pre-workout, the meal that will determine if you are full of energy during your workout, or lazy and tired. For this meal, I recommend having both simple and complex carbs, and again keeping a protein-carb ratio of 1-3. Just to avoid feeling sick, I eat this meal an hour from working out, as well has this meal I recommend a Pre-workout supplement which is a high in caffeine to maximize your workout.
Hope this helps!