zhanghong920
Programmer
I use a Java program to write a matrix data into a file using: DataOutputStream.write() and .writeLong(). But I need to use a C program to read the matrix data. How can I do that?
My Java code (to write the matrix)is:
matrixFile.write(nrow);
matrixFile.write(ncol);
matrixFile.write(nonzero);
for(int i = 0; i < ncol; i++)
matrixFile.writeLong(pointr);
My C code (to read the matrix) is:
fscanf(fp_in2,"%d%d%d",&ncol,&nrow,&nnzero);
for (i = 0; i <= ncol; i++)
fscanf(fp_in2, "%ld", &pointr);
But I got 0 for "nrow", "ncol" and "nonzero", and thus no value from pointr since ncol is 0.
Any suggestions or hints are appreciated. Thanks,
Hong
My Java code (to write the matrix)is:
matrixFile.write(nrow);
matrixFile.write(ncol);
matrixFile.write(nonzero);
for(int i = 0; i < ncol; i++)
matrixFile.writeLong(pointr);
My C code (to read the matrix) is:
fscanf(fp_in2,"%d%d%d",&ncol,&nrow,&nnzero);
for (i = 0; i <= ncol; i++)
fscanf(fp_in2, "%ld", &pointr);
But I got 0 for "nrow", "ncol" and "nonzero", and thus no value from pointr since ncol is 0.
Any suggestions or hints are appreciated. Thanks,
Hong