A cat that has not eaten for 5 days is a pretty sick cat -- so I would really recommend having him seen by your veterinarian today!
There are many things that can cause a cat to vomit -- and a stuck hairball is probably low on the list of probable causes at this point.
Metabolic problems like kidney disease, liver disease, pancreatitis, or IBD (inflammatory bowel disease) can cause vomiting in cats.
If a foreign object like a piece of a toy, etc, was eaten, that can cause vomiting.
Stomach cancer or intestinal cancer can cause vomiting.
Intestinal parasites can occasionally cause vomiting.
Beacuse some of these possibilities are quite serious, you need to get him some veterinary attention today. I suspect he is quite dehydrated and weak from not eating and barely getting water for 5 days.
Good Luck, if you have more questions just let me know.
-Drew
If this answer was helpful, Please click "Accept" so that your deposit can be paid to me, in return for my time spent helping you and your pet.