Look at your use of open/close double quotes on this line:
snprintf(buff2, 1024, "ifconfig eth0 | grep HWaddr | awk '{for(i=0;i<5;i++) sub(":","-",$5); print $5}'");
You are closing the double quotes right before the :. Try escaping the double-quotes within the string with \".