Home » Developing U++ » U++ Developers corner » C strings
C strings [message #5665] |
Sun, 08 October 2006 18:31  |
Shire
Messages: 41 Registered: September 2006 Location: Russia, Yamal peninsula
|
Member |
|
|
C-like strings have a long history. But them have no length information, which can be unsafe ( while(*p) {...} ) and performance loss ( many strlen() calls ). Microsoft marks many of c-like functions as deprecated.
U++ code have many functions with only const char* parameter. Is reasonable to change type of this parameters to some like ConstString?
#define cs_(buff) ConstString(buff, sizeof(buff))
#define s_(buff) ConstString(buff, strlen(buff))
class ConstString
{
const char* pBuffer;
unsigned length;
public
ConstString(const char* p, unsigned length);
// operators, accessors, etc..
}
|
|
|
Goto Forum:
Current Time: Wed Jun 04 15:02:48 CEST 2025
Total time taken to generate the page: 0.24872 seconds
|