#include <iostream>
/*#include <stdio.h>*/
#include "stdio.h"
#include <string.h>
#include <stdlib.h>
void free_buf(char *ptr)
{
free(ptr);
ptr=NULL;
return;
}
int main(int argc, char *argv[])
{
char *p=(char*)malloc(32);
char *q=p;
snprintf(p,32,"%s", "end of world, 2012");
free_buf(p);
q=NULL;
printf("%S\n",p==q?"p=q":"p!=q");
return 0;
}
总是出现这样的错误E:\c++ workspace\test.cpp(18) : error C2065: 'snprintf' : undeclared identifier
Error executing cl.exe.