CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   PlZ help debugging this simple code (

Jinfeng October 6, 2009 14:13

PlZ help debugging this simple code
Hi all,

This code is pretty simple. All it's trying to do is just to read data from a file (data.dat) and then print some data on the console window to make sure the data was read and stored in correctly.

float rho[8]; //one-dimensional matrix for storing data//
int i;
int k=0;
FILE *ifp;
"data.dat", "r");

for(i=1; i<=9; i++)
"%f", rho[k]);

"rho[1]= %f\n" , rho[1]);
"rho[5]= %f\n" , rho[5]);
"rho[8]= %f\n" , rho[8]);

I can interpret the code with no problem, but when I tried to excute it, it gave me this:

FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.

2. Save cas/data under new name.
3. Exit programme and restart to continue.
4. Report error to your distributor.
Error Object: ()

Does anybody know what the problem could be? Any help would be appreciated! Thanks.


Jinfeng October 6, 2009 18:15

Never Mind! I think I found the problem. It should be

fscanf(ifp, "%f", &rho[k]);

Lesson: Small things can cause big trouble.

All times are GMT -4. The time now is 22:16.