[LUGOS-PROG] printf in format

Alen Loncaric netghost at cool.st
Wed Jul 25 06:34:26 CEST 2001


ce ti napises 

int main(void){

float f;
double d;  // ali z doublom 

f=10,254;
d=10,254;
printf("%.4f", f);  // izpise enako kot si vnesel plus ena nicla 10,2540
printf("%.4lf", d); // izpise enako kot si vnesel plus ena nicla 10,2540
return 0;
}
Tako dela v GCC in v G++ in v Visual c++

----- Original Message ----- 
From: Lego Andy <me at andy.cx>
To: <lugos-prog at lugos.si>
Sent: Tuesday, July 24, 2001 3:44 PM
Subject: [LUGOS-PROG] printf in format


> Hojla!
> 
> Klele imam eno trivialno vprasanje:
> 
> Ce das 
> 
> float f = 10;
> cout << f;
> bo napisalo:
> 10
> 
> ce das
> float f=10.324;
> cout << f;
> bo napisalo:
> 10.324
> 
> Ok; kako naredis isto s printf?
> Sem probal printf("%.4f", f); pa vsakic napise
> 
> 10.0000
> 
> Kako bi naredil da se bo obnasal bolj kot <<?
> 
> Andy
> 
> --
>  /\  |  | |~\  \  /      ------------------------------------------------
> /  \ |\ | |  |  \/      / e-mail: andy at x0.org  )\._.,--....,'``.
> |--| | \| |  |  /      /  ICQ: 27889915       /,   _.. \   _\  (`._ ,.
> |  | |  | |_/  /      /   http://andy.x0.org  `._.-(,_..'--(,_..'`-.;.'
> ----------------------                                  
> 




More information about the lugos-prog mailing list