Pelles C forum

C language => Windows questions => Topic started by: blzbb on June 18, 2008, 11:07:00 AM

Title: problem on safer function
Post by: blzbb on June 18, 2008, 11:07:00 AM
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: [Select]
#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 :
Code: [Select]
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
Title: Re: problem on safer function
Post by: JohnF on June 18, 2008, 06:12:38 PM
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: [Select]
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>

John
Title: Re: problem on safer function
Post by: blzbb on June 18, 2008, 07:01:06 PM
thanks John for your reply, it seems it is not bug, just my mistake  ;D