If you don't know for sure what kind of caterpillar you've found, feeding it can be tricky. Most caterpillars are herbivores, eating only plants. Some caterpillars feed on a variety of food plants, while others consume only a specific plant. You can't force a caterpillar to eat something different – it will simply stop eating. A little trial and error may be required to find the proper food for your caterpillar.
Your first and most important clue is where you found the caterpillar. Was it on a plant? If so, there's a good chance that's its food. Take some cuttings of the plant, and be sure to include both new and old leaves, as well as flowers if the plant has bloomed. Some caterpillars prefer old leaves to new ones, and others may feed on the flowers. Offer the cuttings to your caterpillar, and see if it eats anything.
If the caterpillar was not on a plant at the time you found it, you'll have to make some educated guesses about what to feed it. What plants are nearby? Start with those, taking cuttings and offering them to the caterpillar. If it eats one, you've solved the mystery and should continue to collect that plant for feeding.
If you're still really stumped about the caterpillar's food preferences, you can try introducing one or more of the most common caterpillar food plants: oak, willow, cherry, poplar, birch, apple, and alder. Some herbaceous plants, like dandelions and clover, are also common hosts for larvae. When all else fails, try a few bits of apple or carrot.
Whatever your caterpillar does eat, you will need an abundant supply of the food plant. Remember, a caterpillars job is to eat and grow. As it gets bigger, it will eat more. You need to keep a fresh supply of food available to the caterpillar at all times. Change the food once most of it has been eaten, or if it starts to wilt or dry out.