Originally Posted by
lmanukyan
I included <string.h> library, maybe I should add anything else?
I assumed that you left out the header inclusions as they were obvious. Remind me to stop assuming that for you.
This is what gcc 4.8.4 complains about for your code in post #1 when compiling with -Wall -pedantic -std=c99 (or -ansi):
Code:
test.c: In function ‘main’:
test.c:6:5: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
printf( "%s%s\n%s%s\n",
^
test.c:6:5: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
test.c:8:2: warning: implicit declaration of function ‘strcpy_s’ [-Wimplicit-function-declaration]
"The string in array y is: ",strcpy_s( y, x ) );
^
test.c:8:2: warning: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘int’ [-Wformat=]
test.c:9:5: warning: implicit declaration of function ‘strncpy_s’ [-Wimplicit-function-declaration]
strncpy_s(z,x,14);
^
test.c:14:5: warning: implicit declaration of function ‘_getch’ [-Wimplicit-function-declaration]
_getch();
^
Actually, it also gives me these link errors, but these you can ignore them if they are supported:
Code:
In function `main':
test.c:(.text+0x55): undefined reference to `strcpy_s'
test.c:(.text+0x97): undefined reference to `strncpy_s'
test.c:(.text+0xbb): undefined reference to `_getch'
You should include the relevant headers to silence these warnings, and then pay attention to any further warnings that are emitted. If there are no warnings to begin with, you must compile at a higher warning level. If you have been ignoring warnings, then start paying attention to them, or all you will get from me are the warnings from my compiler, if I bother to post at all when encountering warnings from your code.