CSC161 2011S Imperative Problem Solving

Reading: Input and Output in C

Reading: K&R 7.1-7.2, 7.4

Please submit a question by 9 p.m. on Monday, 7 February 2011.


Pointers

What does it mean by pointer when talking about scan?

Can you clarify what an assignment pointer is? Also, what is the purpose of the asterisk in variable names?

For now, just assume that a pointer is something you get by prefixing a variable with an ampersand.


Is the minprintf example just a simplified version of printf?

Not exactly a question, but I'm having a hard time parsing the code for minprintf on page 156. I don't understand why *p is used in some situations and p in others.


Yes.

Is printf essentially an extension of scanf? does our implementation of printf contain scanf?

Is the widened colon shape thing in the book equivalent to the thing we use for pipelines? This thing: | . Because they show it in places where that makes sense but it looks different...

In the samples on page 155, it is stated that printf(s); and printf("%s", s) are very significantly different. Why? What does % do?

What is the difference between pointers and normal arguments to I/O functions? Also, if "name" is a pointer, in the example, then why is it not preceded by a "&" while the other arguments are?

What is meant when it is said that arguments of scanf must be pointers?

In section 7.2 there is a program that converts its input to lower case. What does that section about macros, and how this makes it only pick single characters, (seen directly below the code) mean?

What's the difference between using sprintf and printf? Can we go over an example in class, because the discussion in the book makes little sense.

Could you clarify the distinction between the argument type "e" and "f" in the Table 7.1 Basic Printf Conversions? What does "m.dddddde+/-xx" mean?

Pointers have come up several times in the reading, but have never been really explained. Can you give a 30 second introduction to pointers next class?

Why exactly is "<infile" not included in the command line?

Since the value of EOF is -1, what happens if something that is supposed to stop when it encounters EOF actually encounters -1?

I do not quite get the character e, E and g, G? Also do not get printf (s) and printf ("%s", s)? Also explain more the function of minprintf.

(bottom of pg. 154) Could you explain why/how each "hello, world" string was changed using its given example of a printf conversion?

What forms of input and output can we easily use through the standard library in C?

I did not understand exactly what differences all the signs and notations make while using %s.

Can we also go through the program minprintf and see exactly how it works?

What exactly happens if the arguments to scanf and sscanf aren't pointers?

In the example on page 159, why is 20 chosen as the array monthname's argument?

What does void mean in void minprintf on page 156?

When do I know when to use <stdio.h> and <ctype.h> or any other files?

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Tue Feb 8 10:14:25 2011.
The source to the document was last modified on Tue Feb 8 10:14:22 2011.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2011S/Readings/c-io.html.

Samuel A. Rebelsky, rebelsky@grinnell.edu