CSC161 2011S Imperative Problem Solving
[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazzza]
-
[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]
-
[Current Assignment]
[Current Lab]
[Current Reading]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
[Reference]
Related Courses:
[CSC195 2003S (Rebelsky)]
[CSC161 2009F (Coahran)]
[CSC161 2010S (Walker)]
[CSC161 2010F (Rebelsky)]
Misc:
[SamR]
[ISO]
[GNU Coding Standards]
Reading: K&R 4.3-4.6.
Please submit a question by 9 p.m. on Thursday, 3 March 2011.
Is the push and pop on 4.4 the same thing as the pushd and popd we learned in Scheme?
I think you learned pushd and popd when we started Linux, and it's the same basic concept.
Is it common to store widely used variables such as int x or int (c = getchar(x)) into a source file so that they do not have to be typed every time one writes a program?
It's a bad idea to store commonly-used variables in a separate file, since mulitple programs may use them in slightly different ways, leading to unexpected behavior.
What happens if there is more than one definition of an external variable in the files? Will it still compile or just produce an error?
You should get an error when you try to join them together.
What does it mean to buffer?
Effectively, to store temporarily
.
How does extern know which file to look in for the definition of variables?
You tell it when you link the files together.
Is reverse Polish notation programmed into C?
No.
If you use extern to declare an external variable in a file, file1, does that declare the variable to every file that file1 is compiled with, or just to file1?
It means that file1 will have to look elsewhere for that variable.
Why does static have two different meanings? (Scope an external variable or function to the file it is in, or have an internal variable be persistent through multiple function calls)
Also, what happens if you declare a variable as static in main?
Can you explain static files please? I can't tell if that is supposed to be part of the reading or not, since every page has different information...
Also, how do you create header files? The same as c files but with a .h instead?
"Page 82 is giving me a headache. Well, not literally, but the diagram they present with the layout of files, variables, and functions is a bit puzzling.
How do each file or functions interact with each other. All the subfiles (main.c, getop.c, stack.c, getch.c) include the header file calc.h but they don't seem to include each other. So how does main.c get all the functions that it needs? Does having calc.c included in each file simply ""link"" all the files together and make the functions available to them?"
How do getch and ungetch work together?
How does the register declaration help? I know that it let's the compiler know that the variable in question will be heavily used, but in what way can it do that? Either way, it has to go through all the code, right?
What is the difference between using a header and using an extern declaration? It seems like they are two different ways of making variables/functions accessible from multiple files. Is this understanding correct and is there anything else I should know about it?"
Does the header file have to be compiled along with the others, or does #include headerfile retrieve everything that was needed.
Could you go over how the function getop on page 78 works?
How is it that the code know which files to run at what times for the program not to fail, if the code is spread out into separate files?
I'm not entirely sure what static does. Does it just limit where the variables can be used?
I didn't quite understood stack.c , calc.h, getop.c, and getch.c?
What is the purpose of declaring external variables (as opposed to just defining them when needed)?
What exactly are "push" and "pop" operations in layman's terms?
Can you explain extern a little bit more? I couldn't really get it properly.
Is there a possibility that there are multiple definitions of an external variable?
Can you explain headers? o.o All if talks about are how it appears on files but not what they really do, at least to me.
I don't see the difference between internal and external statics, can you go over them more clearly?
[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazzza]
-
[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]
-
[Current Assignment]
[Current Lab]
[Current Reading]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
[Reference]
Related Courses:
[CSC195 2003S (Rebelsky)]
[CSC161 2009F (Coahran)]
[CSC161 2010S (Walker)]
[CSC161 2010F (Rebelsky)]
Misc:
[SamR]
[ISO]
[GNU Coding Standards]
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 Fri Mar 4 10:50:47 2011.
The source to the document was last modified on Fri Mar 4 10:50:45 2011.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2011S/Readings/libraries.html.