G
G
gleendo2014-09-23 20:20:56
Programming
gleendo, 2014-09-23 20:20:56

Why doesn't it display correctly?

Wrote this

<code lang="c">
#include <stdio.h>
#include <conio.h>
#include <locale.h>

int main(void) {
  setlocale(LC_ALL, "RUS");
  double a;
  printf("Введите число с плавающей запятой: ");
  scanf_s("%f", &a);
  printf("Введено число %f или %e", a, a);
  _getch();
  return 0;
}
</code>

I enter as it is written in the book: 21.290000
Outputs: The number entered is multi-digit or multi-digit
A should output: The number entered is 21.290000 or 2.129000e + 001 Tell me
where did you make a mistake?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Morozov, 2014-09-23
@morozovdenis

I have only one assumption, the book was written by a person who had a computer with a 32-bit processor, and you have a 64-bit one and you need to write like this:
scanf_s("%Lf", &a);

D
Don Kaban, 2014-09-24
@donkaban

LC_NUMERIC with "RUS" - not a comma by any chance? And what for generally SO to put locale? In 2014?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question