vector crash

zjh fqbqrr at 163.com
Thu Jan 18 04:20:12 UTC 2024


On Thursday, 18 January 2024 at 03:53:09 UTC, Steven 
Schveighoffer wrote:

> Are you sure this is what you are wanting to do?
>
> -Steve

```d
void gg(string a){
     Vector!string d=[];toV(a,d);//File to Vector
     print(d);//3,OK
     foreach(e;d){
         string b=e;//.1
         string m=readText(b);ff(m,b);
     }
}
```

`gg`: I want to traverse the 'a' file and then call the `ff` 
function .

But there was an error with the `vector` here, the file had 3 or 
4 lines, but now it crashes on the 3rd line, and when calling 
print seperately, the output is normal.

I think that here `b` copied `e`, even if the `ff` function goes 
wrong, it won't affect `e`. I really don't know why it crashed at 
`.1`?.



More information about the Digitalmars-d-learn mailing list