I am looking at some legacy C code.
char * b = (char *)malloc(l+1) ;
If i were to use new operator, it will be declared as
char * b = new b ;
Would that be correct?
Thx
Lawina
This is a discussion on C++ newbie struggling with malloc within the C++ Programming forums, part of the General Programming Boards category; I am looking at some legacy C code. char * b = (char *)malloc(l+1) ; If i were to use ...
I am looking at some legacy C code.
char * b = (char *)malloc(l+1) ;
If i were to use new operator, it will be declared as
char * b = new b ;
Would that be correct?
Thx
Lawina
This might be more likely:
But then you might just use std::string instead.Code:char* b = new char[l+1];
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
and be sure to use delete in place os the corresponding free().
Code:char* b = new char[l+1]; delete [] b;
Thanks guys.