increment/decrement; use pointer
This commit is contained in:
1 file changed
+6
-5
@@ -39,20 +39,21 @@ public:
|
|||||||
static int Length(const char* str) //static because method is not using object state and don`t need access to class members
|
static int Length(const char* str) //static because method is not using object state and don`t need access to class members
|
||||||
{
|
{
|
||||||
int length = 0;
|
int length = 0;
|
||||||
while (str[length] != '\0')
|
while (*str != '\0')
|
||||||
{
|
{
|
||||||
length++;
|
length++;
|
||||||
|
str++;
|
||||||
}
|
}
|
||||||
return length;// + 1; // Include \0
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CopyString(char* destination, const char* source, int length) //static because method is not using object state and don`t need access to class members
|
static void CopyString(char* destination, const char* source, int length) //static because method is not using object state and don`t need access to class members
|
||||||
{
|
{
|
||||||
for (int i = 0; i < length; i++)
|
while (length--)
|
||||||
{
|
{
|
||||||
destination[i] = source[i];
|
*destination++ = *source++;
|
||||||
}
|
}
|
||||||
destination[length] = '\0';
|
*destination = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
int Length() const { return len; }
|
int Length() const { return len; }
|
||||||
|
|||||||
Reference in new issue
Block a user