Y
ypjofficial
Hello All,
To use sprintf function we have to first create a char * and assign
some memory to it or we have to fixed memory sized array.
eg.
char str[512];//or it can be
//char * str =(char *)malloc(512);
int d=100;
float f=2.22;
sprintf(str,"Test of sprintf %d %f"),d,f);
free(str);
if there any library function which can avoid allocating memory to str.
i.e i can write
char * str = NULL;
and directly pass str to that printf like function and the function
will internally handle the allocation of memory and releasing it.
so i can write the code like
eg.
char * str = NULL;
testprintf(str,"Test of sprintf %d%f"),d,f);
Is there any such library function available?
Regards,
Yogesh Joshi
To use sprintf function we have to first create a char * and assign
some memory to it or we have to fixed memory sized array.
eg.
char str[512];//or it can be
//char * str =(char *)malloc(512);
int d=100;
float f=2.22;
sprintf(str,"Test of sprintf %d %f"),d,f);
free(str);
if there any library function which can avoid allocating memory to str.
i.e i can write
char * str = NULL;
and directly pass str to that printf like function and the function
will internally handle the allocation of memory and releasing it.
so i can write the code like
eg.
char * str = NULL;
testprintf(str,"Test of sprintf %d%f"),d,f);
Is there any such library function available?
Regards,
Yogesh Joshi