Skip to content

Instantly share code, notes, and snippets.

@1995parham
Created December 13, 2019 12:56
Show Gist options
  • Save 1995parham/85d933c5e0037593f944e0d6b301ed56 to your computer and use it in GitHub Desktop.
Save 1995parham/85d933c5e0037593f944e0d6b301ed56 to your computer and use it in GitHub Desktop.
How `scanf` reads input.
#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;
}
@1995parham
Copy link
Author

Run this program and write 2.3 for it. Can you guess the output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment