This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: and ﬁnally a double followed by spaces, tabs, or returns. Bad User • If the user types something bad, then scanf statement will fail. And the variables will contain whatever info was there before. • scanf returns a value equal to the number of variables that were ﬁlled • Example bad_user.c An extra & • printf( “%d”, &age ); – prints the address of age; – 1245060 Forgetting the & • Because we don’t use & for printf and do use it for scanf, we have to be careful not to get mixed up. • scanf(“%d”,age); – stores the value that the user typed in at the location that is equal to age (not at the location of age) – warning argument is not a pointer – run & crash – run & segmentation fault...
View Full Document
- Spring '06
- Trigraph, Articles with example C code, ndit io nals