Lecture 07 - Conditionals

Lecture 07 - Conditionals - and nally a double followed by...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
07 Conditionals Oct. 3, 2006 Announcements • Announcements web-page • A1 Grading • A2 • Reminder to use FAQ • CS-Club Meet and Greet – Wednesday the 4th, at 5:30. It's in Reynolds 212. Review • Functions, function proto-types, function calls. • Return values. • dog_years.c revisited • Skeleton program’s with functions. Review • Last time we saw the scanf statement – Examples • All variables except strings: – scanf( “%d”, &an_integer ); – printf( “%d”, an_integer ); • Exception for strings: – scanf( “%s”, a_string ); – printf( “%s”, a_string ); More complicated format strings &a_double ); • This will read an integer, followed by spaces, tabs, or returns, the a float, followed by spaces, tabs, or returns,
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the 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 dont 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

Page1 / 2

Lecture 07 - Conditionals - and nally a double followed by...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online