Danh mục

C Programming Lecture Notes

Số trang: 191      Loại file: doc      Dung lượng: 955.50 KB      Lượt xem: 15      Lượt tải: 0    
tailieu_vip

Phí tải xuống: 28,000 VND Tải xuống file đầy đủ (191 trang) 0
Xem trước 10 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

These notes are written based on the book The C Programming Language, by Brian Kernighan and Dennis Ritchie, or K&R (The second edition was published in 1988 by Prentice-Hall, ISBN 0-13-110362-8.). The sections are cross-referenced to those of K&R, for the reader who wants to pursue a more in-depth exposition.
Nội dung trích xuất từ tài liệu:
C Programming Lecture NotesKỹThuậtlậptrìnhCHVKTQSC Programming Lecture NotesThese notes are written based on the book The C Programming Language, by Brian Kernighan andDennis Ritchie, or K&R (The second edition was published in 1988 by Prentice-Hall, ISBN 0-13-110362-8.). The sections are cross-referenced to those of K&R, for the reader who wants to pursue amore in-depth exposition.Chapter 1: IntroductionChapter 2: Basic Data Types and OperatorsChapter 3: Statements and Control FlowChapter 4: More about Declarations (and Initialization)Chapter 5: Functions and Program StructureChapter 6: Basic I/OChapter 7: More OperatorsChapter 8: StringsChapter 9: The C PreprocessorChapter 10: PointersChapter 11: Memory AllocationChapter 12: Input and OutputChapter 13: Reading the Command LineChapter 14: Whats Next?Chapter 15: User-Defined Data StructuresChapter 16: The Standard I/O (stdio) LibraryChapter 17: Data FilesChapter 18: Miscellaneous C FeaturesChapter 19: Returning ArraysChapter 20: More About the PreprocessorChapter 21: Pointer Allocation StrategiesChapter 22: Pointers to PointersChapter 23: Two-Dimensional (and Multidimensional) ArraysChapter 24: Pointers To FunctionsChapter 25: Variable-Length Argument ListsChapter 1: IntroductionC is (as K&R admit) a relatively small language, but one which (to its admirers, anyway) wears well.Cs small, unambitious feature set is a real advantage: theres less to learn; there isnt excess baggagein the way when you dont need it. It can also be a disadvantage: since it doesnt do everything for you,theres a lot you have to do yourself. (Actually, this is viewed by many as an additional advantage:anything the language doesnt do for you, it doesnt dictate to you, either, so youre free to do thatsomething however you want.) 1KỹThuậtlậptrìnhCHVKTQSC is sometimes referred to as a ``high-level assembly language. Some people think thats an insult,but its actually a deliberate and significant aspect of the language. If you have programmed inassembly language, youll probably find C very natural and comfortable (although if you continue tofocus too heavily on machine-level details, youll probably end up with unnecessarily nonportableprograms). If you havent programmed in assembly language, you may be frustrated by Cs lack ofcertain higher-level features. In either case, you should understand why C was designed this way: sothat seemingly-simple constructions expressed in C would not expand to arbitrarily expensive (in timeor space) machine language constructions when compiled. If you write a C program simply andsuccinctly, it is likely to result in a succinct, efficient machine language executable. If you find that theexecutable program resulting from a C program is not efficient, its probably because of something sillyyou did, not because of something the compiler did behind your back which you have no control over.In any case, theres no point in complaining about Cs low-level flavor: C is what it is.A programming language is a tool, and no tool can perform every task unaided. If youre building ahouse, and Im teaching you how to use a hammer, and you ask how to assemble rafters and trussesinto gables, thats a legitimate question, but the answer has fallen out of the realm of ``How do I use ahammer? and into ``How do I build a house?. In the same way, well see that C does not have built-in features to perform every function that we might ever need to do while programming.As mentioned above, C imposes relatively few built-in ways of doing things on the programmer. Somecommon tasks, such as manipulating strings, allocating memory, and doing input/output (I/O), areperformed by calling on library functions. Other tasks which you might want to do, such as creating orlisting directories, or interacting with a mouse, or displaying windows or other user-interface elements,or doing color graphics, are not defined by the C language at all. You can do these things from a Cprogram, of course, but you will be calling on services which are peculiar to your programmingenvironment (compiler, processor, and operating system) and which are not defined by the Cstandard. Since this course is about portable C programming, it will also be steering clear of facilitiesnot provided in all C environments.Another aspect of C thats worth mentioning here is that it is, to put it bluntly, a bit dangerous. C doesnot, in general, try hard to protect a programmer from mistakes. If you write a piece of code which will(through some oversight of yours) do something wildly different from what you intended it to do, up toand including deleting your data or trashing your disk, and if it is possible for the compiler to compile it,it generally will. You wont get warnings of the form ``Do you really mean to...? ...

Tài liệu được xem nhiều:

Gợi ý tài liệu liên quan: