C language > Windows questions

problem on safer function

(1/1)

blzbb:
when i compiling program that have some safer function like strcat_s, fopen_s, ...
it give me a error on output, but after building the program work fine

it is my source :

--- Code: ---#include <stdio.h>
#include <string.h>

int main()
{
FILE *fp;
char str1[20] = "h:\\", str2[] = "test.txt";

strcat_s(str1, sizeof(str1), str2);
printf("%s\n", str1);

fopen_s(&fp, str1, "uw");
if ( fp )
{
fputs("this is just for test", fp);
fclose(fp);
}

return 0;
}

--- End code ---

and it is output  log when i juct compile :

--- Code: ---Building test.obj.
H:\Programming\C\test\test.c(9): warning #2027: Missing prototype for 'strcat_s'.
H:\Programming\C\test\test.c(12): warning #2027: Missing prototype for 'fopen_s'.
Done.

--- End code ---

I use PelleC version 5.00.1

tnx

JohnF:
This is not bug - if you are unsure what you are doing post the message in another section of the forum.

You need to define __STDC_WANT_LIB_EXT1__ as 1 before including string.h


--- Code: ---#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>

--- End code ---

John

blzbb:
thanks John for your reply, it seems it is not bug, just my mistake  ;D

Navigation

[0] Message Index

Go to full version