I had an iPhone 5c with a rear camera that showed nothing but a black screen. [Edit] Sometimes it told me my phone was too hot, when it wasn't. [/edit] Interestingly, in FaceTime switching to the rear camera worked fine -- which made me wonder if it was a software issue. Restoring the phone actually worked for a while, but the problem returned.
For the record, this turned out to be a hardware problem for me. I took apart the phone, detached and reattached the camera -- still nothing. So it wasn't a bad contact (as for some others here). However when I fitted a £4 replacement camera part from eBay, it worked immediately. YMMV, but in my case the actual camera part must have been failing, and replacing it worked. Worth bearing in mind as a last resort.