Narrative:

We were in route to the charlotte area from the south in cessna 172 when we encountered an electrical failure shortly after takeoff. I immediately set the transponder to 7600 and continuously tried communicating with nearby towers and approach controls with my handheld radio; but did not receive a reply. Since the electrical failure disabled our mode C transponder I knew that we could not land at our destination airport due to the mode C veil of charlotte B airspace in which it is located. To avoid charlotte class B airspace we were en route to land outside the veil to have the electric fixed and the engine looked at the following day. About 20 miles south/east of that destination the engine started making funny noises and started stuttering. I turned the master switch back on which I had turned off to prevent potential electrical fires and to conserve the battery; declared an emergency by setting the transponder to 7700 and broadcasted it on 121.5 on my handheld and proceeded direct towards my original destination flying through the mode C veil. We landed safely [without] engine failure.

Google
 

Original NASA ASRS Text

Title: C172 pilot experiences electrical failure shortly after takeoff and elects to continue to an alternate destination. Enroute the engine begins to run rough and the decision is made to divert to the original destination beneath Class B airspace.

Narrative: We were in route to the Charlotte area from the south in Cessna 172 when we encountered an electrical failure shortly after takeoff. I immediately set the transponder to 7600 and continuously tried communicating with nearby towers and approach controls with my handheld radio; but did not receive a reply. Since the electrical failure disabled our Mode C transponder I knew that we could not land at our destination airport due to the Mode C veil of Charlotte B airspace in which it is located. To avoid Charlotte Class B airspace we were en route to land outside the veil to have the electric fixed and the engine looked at the following day. About 20 miles south/east of that destination the engine started making funny noises and started stuttering. I turned the master switch back on which I had turned off to prevent potential electrical fires and to conserve the battery; declared an emergency by setting the transponder to 7700 and broadcasted it on 121.5 on my handheld and proceeded direct towards my original destination flying through the Mode C veil. We landed safely [without] engine failure.

Data retrieved from NASA's ASRS site as of July 2013 and automatically converted to unabbreviated mixed upper/lowercase text. This report is for informational purposes with no guarantee of accuracy. See NASA's ASRS site for official report.