Error shows in receiver code for RC4 decryption

Start by changing:

void rc4(char *key, char *data){

to

void rc4(char *key, int keylen, char *data, int datalen){

And using the length parameters instead of calls to strlen(). Change the calls to rc4 to provide explicit lengths,
you'll have to ensure the lengths are knowable (are you sending fixed packet size for instance?).

BTW RC4 is no longer considered secure - you know this?