Someone told me to use the strlcpy
function instead of strcpy
like this
#include <stdio.h>
#include <string.h>
void main()
{
char var1[6] = "stuff";
char var2[7] = "world!";
strlcpy(var1, var2, sizeof(var2));
printf("hello %s", var1);
}
and when I compile the file it gives me the following error:
C:\Users\PC-1\AppData\Local\Temp\ccafgEAb.o:c.c:(.text+0x45): undefined referenc
e to `strlcpy'
collect2.exe: error: ld returned 1 exit status
notice: I have installed MinGW (Minimalist GNU for Windows) and gcc version is 4.7.2
What is the problem?