NO

Author Topic: problem on safer function  (Read 4789 times)

blzbb

  • Guest
problem on safer function
« 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
« Last Edit: June 18, 2008, 11:08:31 AM by blzbb »

JohnF

  • Guest
Re: problem on safer function
« Reply #1 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
« Last Edit: June 18, 2008, 06:19:32 PM by JohnF »

blzbb

  • Guest
Re: problem on safer function
« Reply #2 on: June 18, 2008, 07:01:06 PM »
thanks John for your reply, it seems it is not bug, just my mistake  ;D