problem on safer function

Started by blzbb, June 18, 2008, 11:07:00 AM

Previous topic - Next topic

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 :

#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;
}


and it is output  log when i juct compile :

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.


I use PelleC version 5.00.1

tnx

JohnF

#1
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


#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>


John

blzbb

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