"Ali" <abdulra...@gmail.com>
???????:1182762429.872576.61...@m37g2000prh.googlegroups.com...
On Jun 25, 1:35 am, "Jack" <j...@knight.com> wrote:
The entire function looks like
void appendStrTab (strTable *strTab, char *format, ...)
/* Appends the new line (in printf style) to the string table strTab.
*/
{ va_list args;
va_start (args, format);
if (strTab->numLines == strTab->allocLines)
{
incTableSize (strTab);
}
strTab->str[strTab->numLines] = (char *)malloc(lineSize *
sizeof(char));
if (strTab->str == NULL)
{
fatalError(MALLOC_FAILED, lineSize * sizeof(char));
}
vsprintf (strTab->str[strTab->numLines], format, args);
strTab->numLines++;
va_end (args);
}
You see that most of the statements of this function is unmanaged.
I prefer using std to crt, so I want to alter this program (open-source)
in
my own style
Thanks
Jack
Maybe this can give you an idea.
http://www.cplusplus.com/reference/clibrary/cstdio/vsprintf.html
ali
Hello ali,
I've read thru the page :) And also at the same time, I went over cstdio,
there is a line "using ::vsprintf"
I wonder what that is... :)
My function uses malloc as the heap allocation method. :)
strTab->str[strTab->numLines] = (char *)malloc(lineSize * sizeof(char));
this buffer expands and shrinks as the program passes a new size to the
function. :)
I'd like to make it automatically managed, so that I don't have to
re-allocate the heap each time
the thing is called. Also, I need to make my function more consistent with
the rest of my program
So I got stuck on this..... :)
Having said that, I think this isn't possible without using char *, I'd
really eager to use std::string.
so that I won't have a piece of this over here and a piece of that over
there.
Hope you understand..... And sorry I have to make you repeat again.....
Thanks
Jack