Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

Блог пользователя bharadwaj75

Автор bharadwaj75, 9 лет назад, По-английски

printf("%d",scanf("%d",&a)) gives always 1 .Can any one tell what is the actual logic behind that?

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

printf returns the number of items of the argument list successfully filled normally, in this case the return value is 1.

For more, view the section "Return Value" on this page.

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

It is not necessary 1, obviously the answer is the output of scanf(...), and if it works properly it is all the variables it could, read or -1 in eof

»
9 лет назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

scanf returns the number of read items.

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

1 means true