Posted By: NNH
Problem with file_str_read... - 05/15/13 09:48
When I'm trying to run this code, it gave me this error: "Crash in import". But if I comment out the following lines:
it runs fine. What am I doing wrong?
Here's my code:
And these are two files contain the data:
ddat.txt
Na,Na,Be,
did.txt
0 1 5
Code:
while(i < c && ddat != -1) { // file_str_read(ddat,read); box[i].name = read; // box[i].id = file_var_read(did); i++; wait(1); }
it runs fine. What am I doing wrong?
Here's my code:
Code:
#include <acknex.h> #define c 3 typedef struct chembox { STRING *name; int id; int state; } chembox; void import(); ////////////////////////////////////////////////////////////// chembox box[c]; void import() { int i = 0, ddat, did; STRING *read = " "; ddat = file_open_read("ddat.txt"); did = file_open_read("did.txt"); while(i < c && ddat != -1) { file_str_read(ddat,read); box[i].name = read; box[i].id = file_var_read(did); i++; wait(1); } if(!ddat) file_close(ddat); if(!did) file_close(did); } void main(void) { level_load(""); import(); wait(1); }
And these are two files contain the data:
ddat.txt
Na,Na,Be,
did.txt
0 1 5