Hi Rooters, I'm trying to implement am existing C program which reads the neutron data files from ENDF. Since the file is quite complicated I want to use a program already written by somebody else. I'm curently using it with CINT inside root. I had to do some adjustements but I am facing a problem which I don't understand. I give the pieces of the code where the problem occurs /*Global variables */ #define MIN(A,B) ((A)<(B)) ? (A) : (B) char xfr_buf[128], *b66 = xfr_buf+ 66; /*global too */ I'm doing then several call to the function endf_scan written below. The calls are in a loop endf_scan(xfr_buf,dv,MIN(rest,6)); the local variables are defined as double dv[2]; long rest; For the first step of the loop everything is OK, but in the second step I have an error Error: strncpy param[1]=0 must not be 0 Printing the value of b and v shows that for the second call all the arguments of endf_scan are null. I verified that the arguments before the call i.e. xfr_buf and dv are non-null. I really don't understand what's happening. Thanks in advance. /* ................................................. ENDF_SCAN * Scan an ENDF HEAD or TAB1 record b into d.fl.pt. vector v */ int endf_scan(char *b, double *v, int lim) { int k, rv=0, mant; char buf[14],*p; buf[13]=EOS; cout << "In endf_scan"<<endl; printf("b adress = %i b content %s\n",&b,b); // printf("****\n%80s", b); for ( k=0; k < lim; ++k, b += 11){ strncpy(buf, b, 11); p = strpbrk(buf + 1, "+-"); if (p != NULL){ mant = p - buf; strncpy(buf, b, mant); p[0] = 'E'; p[1] = b[mant]; p[2] = (b[mant+1] == ' ')? b[mant+2] : b[mant+1]; p[3] = ' '; } /*printf("%s\n", buf);*/ printf("print before scanf ); rv += sscanf (buf, "%lf", v + k); } /******* for (k = 0; k < rv; ++k) printf("%g\t", v[k]); printf("\n"); if (rv == 6) ags_exit ("STOP"); ********/ cout << "out endf_scan"<<endl; return ( rv ); }
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:53 MET