|
[Sponsors] |
February 18, 2024, 09:04 |
problem with reading data from txt file
|
#1 |
New Member
amina
Join Date: Feb 2020
Posts: 9
Rep Power: 6 |
hi everyone ,
I want to know if my data file (containing 20,000 values) is being read by the udf. To do this, I've created a small program that reads the data from the data.txt file and prints it to another file (data1.txt). My program compiles well, the library is created and I've hooked my udf to execute on demand. The data.txt file contains 4 values: 0.2 0.2 0.1 0.1 results on file data1.txt are : 0.000 0.000 0.000 0.000 ????????? where is the problem???? this is my udf: #include "udf.h" double coef[4]; DEFINE_ON_DEMAND(lire) { FILE* rfile; FILE* rfile1; rfile = fopen("C:\\Codes\\data.txt", "r"); rfile1 = fopen("C:\\Codes\\data1.txt", "w"); int i; i = 0; for (i = 0; i <4; i++) { fscanf(rfile, "%f", &coef[i]); fprintf(rfile1, "%f", coef[i]); } fclose(rfile); fclose(rfile1); } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom Thermophysical Properties | wsmith02 | OpenFOAM | 4 | June 1, 2023 15:30 |
SparceImage v1.7.x Issue on MAC OS X | rcarmi | OpenFOAM Installation | 4 | August 14, 2014 07:42 |
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 | keepfit | ParaView | 60 | September 18, 2013 04:23 |
[swak4Foam] build problem swak4Foam OF 2.2.0 | mcathela | OpenFOAM Community Contributions | 14 | April 23, 2013 14:59 |
Version 15 on Mac OS X | gschaider | OpenFOAM Installation | 113 | December 2, 2009 11:23 |