Char * buff; int LENTH = INTVAL; newFunc (?, intVal); // What should I write here? // newfunc () How should I declare?
Let's talk about the statement and definition of the newfunc () function first, the declaration is as follows:
INT newfunc (char ** buff, int buffsize);
Defined as follows:
INT newFunc (char ** buff, int buffsize)
{
Char * tempbuff = null; // If directly * buff = new char [buffsize];
// If the application fails, * buff is required to NULL
Try {
Tempbuff = new char [buffsize];
}
Catch (...) {
Return -1;
}
* BUFF = Tempbuff; // After the memory application is successful, the memory is handed over to the outside.
Return 0;
}
INT newFunc (char ** buff, int buffsize)
{
Char * tempbuff = null; // If directly * buff = new char [buffsize];
// If the application fails, * buff is required to NULL
Try {
Tempbuff = new char [buffsize];
}
Catch (...) {
Return -1;
}
* BUFF = Tempbuff; // After the memory application is successful, the memory is handed over to the outside.
Return 0;
}
Parameters BUFF is a secondary pointer
The method of calling newFunc () is as follows:
NewFunc (* buff, intVal);