Created
December 13, 2019 12:56
-
-
Save 1995parham/85d933c5e0037593f944e0d6b301ed56 to your computer and use it in GitHub Desktop.
How `scanf` reads input.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) { | |
int count = 0; | |
while(1) { | |
printf("count: %d\n", count++); | |
int i; | |
int n = scanf("%d",&i); | |
if (n != 1) { | |
printf("scanf cannot read anything\n"); | |
return 0; | |
} | |
printf("%d\n",i); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run this program and write
2.3
for it. Can you guess the output?