关于可选函数
本人对可选函数相当的疑惑
。。#include<string.h> 书上说有了这个头文件就可以使用可选函数。。并且还要定义这样的东西#define __STDC_WANT_LIB_EXT1__ 1 才可以使用
然而,这两个我都用了。。但是当我用可选函数的时候就是不能运行,而且出现大堆的错误。。
程序代码:#define __STDC_WANT_LIB_EXT1__ 1
#include<string.h>
#include<stdio.h>
int main(void)
{
char preamble[]="the joke is:\n\n";
char str[][40]={
"my dog hasn\'t got any nose.\n",
"how do yours\n",
"my dog smells horrible.\n"
};
unsigned int strCount = sizeof(str)/sizeof(str[0]);
unsigned int length = 0;
for(unsigned int i = 0;i<strCount;++i)
length +=strnlen(preamble,sizeof(str[i]));
char joke[length + strnlen(preamble,sizeof(preamble))+1];
if(strncpy(joke,sizeof(joke),preamble,sizeof(preamble)))
{
printf("wocao!!");
return 1;
}
for(unsigned int i=0;i<strCount;++i)
{
if(strncat(joke,sizeof(joke),str[i],sizeof(str[i])))
{
printf("wocao ????");
return 2;
}
printf("%s",joke);
return 0; 这究竟是怎么回事?求解决。。 一直说 该函数在这范围内没有被声明。。








