Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how i can read data from file to computations

Status
Not open for further replies.

J_expoler2

Member level 4
Member level 4
Joined
May 10, 2003
Messages
77
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
619
ex data from file ex aa.txt
//
10.7939453125
5.7196457736
1.6390841007
1.4315398899
1.6162836208
//

i use command;
fscanf(fp,"%d.%d",&d1,&d2);
i want use data to process but data read from file are incorrect
how i programming (C++)
thank
 

Read in the data in a char array, then transform them to form intergers
 

Hello,

Try this code snippet, it should work:

FILE *F;
double dtmp;
float ftmp;

if((F = fopen("aa.txt", "r")) == NULL)
{
//Cannot open input file
return;
};

while(!feof(F)) //while not end of file
{
fscanf(F, "%lf\n", &dtmp); //this line is for variable type "double"
//fscanf(F, "%f\n", &ftmp); //this line is for variable type "float"
};

fclose(F);
 

how do you say do this
say i want to put form30.text1 (integer)
form30.text2 (string)
etc
how do you put them into a file.. and how would you take them back out.. cause i'm still a bit confused with that. Anyways it's for like a load/save thing in the game i'm making Lands of Crom.

Thanks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top