I got this piece of code
#include<stdio.h> #include <stdlib.h> int main() { int i; int number, S; float MO; S = 0; for(i=0;i<10;i++) { printf("AAA %d\n", i ); scanf("%d\n", &number); S = S + number; } MO = S/10; printf("%d , %f \n",S , MO ); return 0; }
when execution begins, AAA 0 is issued. Then I give my first number. After that, I expect to see AAA 1, but this will only be printed after I give the second number. Checked here
C / C ++ printf () before scanf () problem
but it seems like I can't get any of these solutions to work for me
, , - , . . \n scanf() scanf() . , . C11 §7.21.6.2 5:
\n
scanf()
, () , ( ) . .
OP , . scanf(). , (Stephan Lechner), , , ( ), EOF scanf(). , OP EOF . OP , :
EOF
1 2 3 4 5 6 7 8 9 10 11
, \n scanf(). .
\n scanf:
scanf
scanf("%d", &number);
"\n" . scanf("%d", &number) @Michael Walz .
"\n"
scanf("%d", &number)
scanf("%d\n", &number);
"%d" . . stdin. , int number.
"%d"
stdin
int
number
"\n" 0 , '\n', ' ' . , , stdin.
'\n'
' '
, (1).
2. Return '\n', scanf().
stdout, , \n fflush
stdout
fflush
Source: https://habr.com/ru/post/1667921/More articles:How to switch angular2 class using * ngIf - angularWhere do cores store their datasets when using the docker container? - deep-learningPandas - Processing NaN in categorical data - pythonHow to set up an exception page for developers in Asp.Net Core? - c #Anaconda Navigator creates a new environment and it does not appear - anacondaЦентр фиксированного размера ImageView горизонтально в родительском ConstraintLayout - androidC Programming - The Role of Spaces in scanf () - cAPI веб-аудио: поток микрофона для уменьшения громкости динамика? - javascriptRails 5: How to pass collection_select values through strong_params to fields_for? - ruby | fooobar.comJavaScript regex to match multiple optional lines in any order - javascriptAll Articles