Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters > C/C++

Reply
 
Thread Tools

reading a double from a text file
Old 25.08.2008, 18:58   #1
bored elephant
 
Floyd's Avatar
 
Join Date: 08 2005
Location: Valadilene
Posts: 332
Rep Power: 4
Default reading a double from a text file

Joghovurd, mi hat ankap harc unem, ete karag ogneq, plz

Uremn unem text file "input.dat" meje "20 60 50.0" (verjum el new line ka)

Hima uzum em C-um kardam et tvere...
________________________________________________
...
int membrane_x_size = 0, membrane_y_size = 0;
double membrane_height = 0.0;
...
FILE *inpPtr;

if((inpPtr = fopen("input.dat", "r")) == NULL)
printf("File could not be opened\n");
else{
while(!feof(inpPtr))
fscanf(inpPtr, "%d %d %f\n", &membrane_x_size, &membrane_y_size, &membrane_height);
};

printf("x size = %d cells \ny size = %d cells \nmembrane_height = %f\n", membrane_x_size, membrane_y_size, membrane_height);
...
____________________________________________________

Hima probleme ena vor en amenavereve membrane_height-e sahmanem vorpes float, normal karduma, baytc vor double-em sahmanum, gjvuma u tpeluc tpuma menak 0.00000.

Inchqan nayum em chem karum gtnem.

Inch float sahmanem, heto cast anem double?

Mekel inchqan jokum em float-e aveli "vata" qan double-e che (inchvor 64 bit vs 32 bit, ban-man...)
__________________
"The only verdict is vengeance; a vendetta, held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous" - V

Old 25.08.2008, 20:18   #2
Младенец
 
Join Date: 05 2007
Location: Yerevan
Posts: 12
Rep Power: 0
Default

double kardalu hamar petq a voch te "%f" ogtagordzel, ayl "%lf"

zulu

Old 25.08.2008, 20:28   #3
Ego coder
 
AvDav's Avatar
 
Join Date: 07 2004
Location: Yerevan, Armenia
Age: 44
Posts: 3,738
Rep Power: 5
Default

principi ete et tivt 3.4E–38 -- 3.4E+38 sahmanneruma karas float ogtagorces, double@ krknaki avel texa gravum sovorabar
__________________
Каждый сам кузнец своего счастья, и несчастья тоже.

Old 25.08.2008, 20:34   #4
bored elephant
 
Floyd's Avatar
 
Join Date: 08 2005
Location: Valadilene
Posts: 332
Rep Power: 4
Default

Quote:
Originally Posted by zulu View Post
double kardalu hamar petq a voch te "%f" ogtagordzel, ayl "%lf"

zulu
Mersiner, voobshem ashxatec, et lu-n er!
__________________
"The only verdict is vengeance; a vendetta, held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous" - V
Reply




Реклама:
реклама
Buy text link .

All times are GMT. The time now is 15:30.
Top

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.