Код: Выделить всё
int main ()
{
long a;
char b[100];
a=6/2.5;
sprintf(b,"%i \n",a);
printf("%s",b);
}
Модераторы: Hawk, Romeo, Absurd, DeeJayC, WinMain
Код: Выделить всё
int main ()
{
long a;
char b[100];
a=6/2.5;
sprintf(b,"%i \n",a);
printf("%s",b);
}
спецификацию к *printf почитатькак преобразовать с точкой?
Код: Выделить всё
int main ()
{
long a;
char b[100];
a=6/2.5;
sprintf(b,"%.2f \n",a); /* печать с двух знаков после точки */
printf("%s",b);
}
Пример:Converts a floating-point value to a string, which it stores in a buffer.
char *_gcvt(
double value,
int digits,
char *buffer
);
Parameters
value
Value to be converted.
digits
Number of significant digits stored.
buffer
Storage location for result.
Return Value
_gcvt returns a pointer to the string of digits. There is no error return.
Код: Выделить всё
char Bf[20];
double VAL = 1.234;
gcvt(VAL,5,Bf);
Код: Выделить всё
double GetDlgItemDouble(HWND hDlg, int id)
{
TCHAR *pEnd;
TCHAR szItemText[20];
GetDlgItemText(hDlg, id, szItemText, 20);
return strtod(szItemText, &pEnd);
}