Ya I don't know why he wants us to ignore the null terminator but he does. So I am at a standstill with this for now I guess. any idea how I could code this for loop? I cant really go any farther without it.
Well, first you need to create a good skeleton for your for-loop:
for(size_t i = 0; i < sz; ++i) {
// Other code here
}
This for-loop will run the same amount of times, as the amount of characters there are in the original string (null terminator not included).
This is exactly what we need.
Now we have the for-loop skeleton, we can start adding features to copy the whole thing to a non null-terminated character array inside the class:
// Our copy routine:
for(size_t i = 0; i < sz; ++i) {
p[i] = original[i];
}
In the above example I assume that p is a pointer to the newly allocated memory to hold the non-null-terminated copy of the original string.
original in my example is the string you pass via the class' constructor.
sz is the value you get by using the strlen-function like this: sz = strlen(original);
(I want to note that sz has size_t as it's type).