I am trying to compile a very simple C code in VS2013. I did a bit of Googling beforehand and I realised I need to follow certain steps for that e.g. change the compiler from Default
to Compile As C Code
in my project properties.
The problem is that when I compile following code:
#include <stdio.h>
main()
{
printf("Hello World! \n");
sleep(5);
}
I get these errors:
Error 1 error LNK2019: unresolved external symbol _sleep referenced in function _main
Error 2 error LNK1120: 1 unresolved externals
And if I change the code to:
#include <stdio.h>
#include <Windows.h>
main()
{
printf("Hello World! \n");
Sleep(5000);
}
Then it works fine.
How can I get my first code compiled successfully? I have some tested codes in C and I need to use them. If I couldn't resolve above issue, then I have to update all syntaxes.