| lmd141 (27) | |||||
|
Hi there, I have a function that reads data from a text file, like so:
Which is then used in the main file like so:
The purpose of this loop is to create a coordinate system consisting of randomly generated coordinates inside these (x,y,z) points that have been input from the text file. Now, the problem is that when I run the program I get an unhandled exception during the last loop I've shown here. I suspect it is something to do with array sizes but I'm a bit confused by this. Does anyone notice something I've not? Cheers | |||||
|
|
|||||
| kbw (5375) | |
| That's a very odd way to increment k. What is the value of n_atoms_methane? Is it 5000? If not, where did that 5000 come from? | |
|
|
|
| MikeyBoy (175) | |
|
My guess is that you're trying to write past the end of the coords_fluid array. You're not given us enough information to know for sure, as we don't know what the value of n_atoms_methane is. Your best bet is to use a debugger, or add some debugging output. That will give you an idea of the state of the loop when it crashes. In particular, you'll want to look at which element of coords_fluid is being written to when it crashes. | |
|
|
|
| theranga (54) | |
apparently, x_point, y_point, z_point and type_point all have a size of 5 (assuming that they are the arrays referenced in void coords. If so, why does the loop over j only iterate from 0-3?
| |
|
|
|
| Grey Wolf (3172) | |
Would you not want k=k+1; after the rand() stuff?You look like you are indexing coords_fluid[][] from [1][0] not [0][0].
| |
|
|
|