Armenian Knowledge Base  

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

Reply
 
LinkBack Thread Tools
Old 25.08.2008, 19:58   #1
bored elephant
 
Floyd's Avatar
 
Join Date: 08 2005
Location: Valadilene
Posts: 332
Downloads: 14
Uploads: 0
Reputation: 145 | 3
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
Reply With Quote
Old 25.08.2008, 21:18   #2
Младенец
 
Join Date: 05 2007
Location: Yerevan
Posts: 12
Downloads: 7
Uploads: 0
Reputation: 4 | 0
Default

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

zulu
Reply With Quote
Old 25.08.2008, 21:28   #3
The splendid
 
AvDav's Avatar
 
Join Date: 07 2004
Location: Pure thoughts
Age: 36
Posts: 3,408
Downloads: 22
Uploads: 0
Reputation: 222 | 3
Default

principi ete et tivt 3.4E–38 -- 3.4E+38 sahmanneruma karas float ogtagorces, double@ krknaki avel texa gravum sovorabar
Reply With Quote
Old 25.08.2008, 21:34   #4
bored elephant
 
Floyd's Avatar
 
Join Date: 08 2005
Location: Valadilene
Posts: 332
Downloads: 14
Uploads: 0
Reputation: 145 | 3
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!
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 03:16.


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