Well, the c_scan function DOES set the "you" pointer to the closest entity found; However, the reason for the crash is propably that the scan did not find anything, so the "you" pointer remains empty.
You need to check if "you" is empty before you use it:
if(you != NULL)
... // go on here
BUT, snake's solution is much simpler and better either way, so I don't see why you should use c_scan. Do it like snake proposed, that's pretty certainly working.