Warning Messages with the strcpy, strcat and strlen functions
Hello, I am having error messages when using the above functions in linux mint 17. Here is my code and the terminal message.
Code:
#include<stdio.h>
main()
{
char name[16];
char string2[40];
int length;
strcpy(name, "Mark");
strcpy(string2, "My name is ");
strcat(string2, name);
strcat(string2, "\n");
printf(string2);
length = strlen(string2);
printf("The length of this string >>%s<< is %d characters \n", string2, length);
return 0;
}
[Result]
gs_2.c
strings_2.c: In function ‘main’:
strings_2.c:10:1: warning: incompatible implicit declaration of built-in function ‘strcpy’ [enabled by default]
strcpy(name, "Mark");
^
strings_2.c:12:1: warning: incompatible implicit declaration of built-in function ‘strcat’ [enabled by default]
strcat(string2, name);
^
strings_2.c:15:1: warning: format not a string literal and no format arguments [-Wformat-security]
printf(string2);
^
strings_2.c:16:10: warning: incompatible implicit declaration of built-in function ‘strlen’ [enabled by default]
length = strlen(string2);
^
[/Result]
Thanks in advance for your help: