Why I'm getting this "Range Violation" error?
rempas
rempas at tutanota.com
Fri Jul 9 07:21:06 UTC 2021
I have the following code:
```
import core.stdc.stdio;
void print(T)(string prompt, T args...) {
size_t len = prompt.length;
size_t i = 0;
while (prompt[i] != '{' && i < len) {
printf("%c", prompt[i]);
i++;
}
}
void main() {
print("Hello, world!\n", 10);
}
```
When I execute it, I'm getting a range violation error. If I try
to set "len" to be the length of the "prompt" minus 1, then it
will work and it will print the "prompt" until the questionmark.
So I cannot find where the error is...
More information about the Digitalmars-d-learn
mailing list