This is the traditional translation of "C frequently asked Questions" found from Taiwan http://www.cis.nctu.edu.tw/chinese/doc/research/, found "C Frequently Asked Questions" Ye Bingzhe, also the translator of "C Programming Language" 3 / e, this article is very good, paying it for learning purposes, I have not obtained the author's authorization, the copyright of the original article is still home, C FAU solution ============================================================================== ========= ■ □ Section 2: How do I participate in discussions? (Please read it before sending a letter) ========================================= ============== q1: Which discussion area should I ask? Comp.lang.c is the best place to discuss the C language itself (such as: C programming, grammar, style). Other discussion areas are used to discuss specific systems (such as: MS Windows or UNIX), or other and C languages that are not directly related (such as how to use your compiler). List some of the very popular discussion districts and extract some pieces from their FAQs, which should make you understand which topics are most commonly discussed. Comp.os.ms-windows.programmer.tools This area is used to discuss the selection and use of the Windows Software Development System Tool. Comp.os.ms-windows.programmer.misc This is the matter of this and the rest of Windows software development. [There is a FAQ list, list all comp.os.ms-windows.programmer. * Discussion area] FAQ 5.7.1. Take C object category FAQ 6.1.1 in the DLL. Dialog box is made in the MDI sub-window [Use OWL] FAQ 6.2.1. You can enable the option of the ban [MFC] FAQ 8.1.5. Use the strict symbol definition of Windows.h.h to define FAQ 10. Program design reference information comp.os.msdos.Programmer Many letters It is about program language products (mainly Borland and Microsoft).
FAQ 301. How can I read characters without [Waiting] ENTER key? FAQ 412. How to read, build, change, and delete disk ID? FAQ 504. How to set COM ports to use it to transfer information? How can the FAQ 602. C procedure send the handle to the printer? FAQ 606. How can I know the location and button status of the Microsoft mouse? FAQ 707. How to usually write a project (TSR) tool? FAQ B0. How to connect [Borland, Microsoft] and other companies? [Note: This FAQ is not in RTFM.Mit.edu; in SIMTEL (such as Oak.Oakland.edu) IN / PUB / MSDOS / INFO / FAQP *. ZIP and Garbo (Garbo.uwasa.fi) in /pc/doc-net/faqp*.zip] Comp.os.msdos.Programmer.Turbovision [Borland text mode application skeleton] Comp.unix.programmerfaq 4.5) How to use POPEN () open the itinerary to read and write? FAQ 4.6) How to sleep within the C program? Comp.unix.Solaris (including SunOS 4.x and Solaris) FAQ 4) Signal Getting Started FAQ 5) Wait for the sub-stroke EXIT GNU.G . Helpfaq: Where to find C DEMANGLER (anti-signature encoder)? FAQ: Where is the Solaris 2.x version of the GCC / G bit file? FAQ: Is there a file with G 2.x? GNU.g . BUG [G bug list - please see the G file] Comp.lang.cfaq 1.10: I am joined. NULL guarantees must be 0, but the NULL pointer is not? FAQ 2.3: What does it mean to "pointers and array equivalents in C"? FAQ 4.2: [Why "Printf ("% D / N, "i * i );" Is there a problem? ] FAQ 7.1: How to write a function of receiving unprivilular arguments? [Stdarg.h or varargs.h] FAQ 10.4: How to declare a pointer array pointing to some function, and the feedback value of the function is: pointing to another A function of returning a character pointer? And please refer to your desk, comp.programming, and comp.object (its FAQ is a great OOP Getting Started, the terminology is an instructional). Remember: Comp.std.c is a matter of special discussion and ANSI / ISO C standard solutions (hereinafter mentioned) "" directly ". At the same time, I will ask the same question at the same time to ask the same question, almost unnecessary (you know, the reader of the specific system channel does not need a machine language writing program). Just because of your question "Really Tight", it is a bad habit. If you don't get echo in the "correct" believer, and think that you can send it here, please consider at least, re-directed the reply here back to the appropriate letter. Before you ask questions, you should read its FAQ first. You may ask what you may ask, so you can save time you send a letter, and thousands of people around the world read your letter.
Answer is already a FAQ problem, may be annoyed because of white waste; they may give you a wrong or incomplete answer, because they have never seen FAQ. "Frequently Asked Questions" file can be from anonymous ftp (RTFM.Mit.edu /pub/usenet/comp.what.edu /pub/usenet/comp.what.ever) 24 hours a day (send one "Help" to Mail -server@rtfm.mit.edu. For more information, see "Introduction to the * .answers NewsGroups" file, it is found in News.answers or news.announce.newusers (there are many files that must be read). ================================================================ My procedure What is wrong with problems? Under the end, it is some suggestions, lets the readers of Comp.lang.c help you solve the problem of programming. 1. Please read the previous problem to determine your problem is for the C language itself, and your program design system (such as: drawing, printer, device ...) or compile the environment (such as: "Integration environment hangs "," How to eliminate XXXX Warning Information "," How to connect link ") is completely unrelated. If you want to know why the virtual function in your OWL program cmok () is not called, your problem may be more suitable for the WIDOWS programming channel. If you can write a separate applet, it will make the compiler generate the same error message or behavior with your OWL program, you can put it in comp.lang.c , other system C programmers may help Busy. 2. The "Letter Title" field is meaningful. As is the title of "C program", "New a multi-dimensional number of multi-dimensional groups" is very good. Don't use a bunch of exclamation points, poor "Help", or joking this title with "SEX SEX SEX". If you think this problem is related to your compiler, it is best to write a compiler and version number in the title bar. 3. List the complete, compile the past program code. It is extremely difficult to remove the wrong or rebuild a program from the human language narrative. "Complete Program Code" refers to: Any type used in use, the function must be announced, and the header file that is used is #include to come in ... Wait. Please cut the program code to only the necessary parties, we don't need "useful" "" useful ", we only need to reproduce your error message (possibly in different compilers) It is ok. "Can compile the past" means: Do not contain a bunch of unbounded ... This deletion number, or the line number of the first line: 14: #include
4. List your compiler, compiler version, and the system you use. I know that I have just said: The problem of a particular system should go to a specific letter of information, but the information related to the compiler often helps the investigation problem ("喔, I remember that there is a lot of problems in this regard"), This also reminds users of the compiler: Be careful of those problems. 5. Write the compiler, the options of the tattoo, and the link library you use to use. 6. Write the error message and wherever the error occurs. Like "virtual function can't be used", it did not tell us that this is a compilation period, and the link time is still a problem. If this problem occurs during the execution period, put its behavior, and any related system setting information. 7. List the true E-mail address in the signature file. If you have an error in the "from:" column, please inform you the system administrator. Before it fixes, add the "Reply-to:" column in your letter header, and fill in your correct E-mail address. 8. Read other parts of this FAQ - maybe your problem, or very relevant issues is here. Thank you, and hope that the above recommendations can help you find a solution. =================================================================================================================================================================== ================================== q3: What is OOP? What is C ? Object Guide (OO) program technology is our best way to develop large and complex software systems. C is an object-oriented program language. C can be used as an object-oriented language (OOPL), or it can be used as a "better C language". However, if you only treat it as "better C", you can't get the benefits of object-oriented programming. Applying an OO advertisement: Software industry is unable to cope with large and complex software system requirements. But this is what is because of our "results": our past success prompts everyone to have more, unfortunately, this market is craving is "Analysis), Design, Design, and procedures The design cannot be satisfied. Therefore, we have to develop a better model (Paradigm). ========================================= q4: C advantages? "C growth": C is the most popular language so far.
Users using C every 7.5 to 9 months will double. "I understand C " is a good job search (but you have to treat it as OOPL, not just a better C to use it). "Encapsulation Encapsulation": By hiding the internal data structure, we can change some part of the system without having to fill other parts. We provide a secure interface for software components (called Class, Category), users only touch this interface; and relatively easy to change the interface "Press" part, it is encapsulated (just like being packaged) In the capsule) to avoid the fact that users are too dependent on him. In a relatively simple C, it can be applied by static data within the module to avoid other modules to access it. "Multi-Case Multiple Instances": Typical C Language "Package" method (just mentioned), do not do multiple information cases (we are hard to make multiple cases for "Static" data for the module). If you want to do in C, we have to use the "Struct" structure (but it does not "encapsulate"). In C , we can use "class" to do multiple cases and encapsulation: "public" public part contains its interface (usually there is a special function here: member functions), "private" Private part contains its actual details (usually here is the internal data structure). "In-line function call": In C, you can put a "VOID *" in the Struct (this access function [accessFunctions] can be used to achieve "packaged structs". This will lose the type of security and cause too much function call, even if you only access small fields in the structure (if you allow direct access to the field, it is difficult to change. Because your program has too many places "dependent" it looks like.). The additional burden of the function call is not large, but it will accumulate. The C category allows the function to be extended in the "Inline" line, the following benefits: Package security, Multi-case convenience, Direct access. Moreover, the compiler also checks the parameters of the line function, which is better than the #define macro of C. "Multi-load operand": C can be multi-loaded to the operand of object categories, to comply with our intuition (for example, "MyString YourString" can do string, "MyDate " can be used to increase the date "Z1 * Z2" multiplies two plots Z1 and Z2, "A [i]" can be used to access the i-th element of "A" link serial ... Wait). You can even make a "smart pointer" to point to disk or else ("x = * p" can dereference [decomposition] pointer, you can find P in the disk " To "place, and back it).
This allows the user to write programs in a way that is close to this problem, rather than the language of the machine. [Translation] STL (STANDARD TEMPLATE LIBRARY) uses a large number of "smart pointer" features. "Inherited Inheritance": We are just in the surface, in fact, we have not entered the "object-oriented" part! Suppose you have a Stack Stack type, there is a Push, POP operation. If you still want an invertablestack type, it "very much like" stack, just it has a "invert" operation. With C, you are not to modify the existing Stack module (if it is used in other places, it is troublesome), you have to copy Stack to another file, and modify it (this will cause Multiple procedures, easy to destroy some small places from Stack in Invertables, especially, to maintain double program code). C provides a cleaner solution: inheritance. You can say: "InvertableStack inherits everything of Stack, and Invertables has added invert to operations." This is fine! The Stack itself is still closed (not being fooled), and Invertables has not repeated program code such as Push / Pop. "Multi-type" and "Dynamic": OOP real power is not only inheritance, but also the ability to transmit invertables as a Stack to pass. This is safe, because (at least in C ) This is the relationship of "is a ..." ("IS-A" Relation), through the public inheritance (ie: invertablestack "is a" stack, It can also be self invert to reverse). Polymorphism and dynamic tuning are easier to understand from an instance, so I will give a typical example: drawing software to handle round, square, rectangles, polygons and straight lines, these are "shape shape . Most of the internal functions of most drawing software require a "shape" parameter (relative to some "square" specific shapes), such as: When we select a graphic with the mouse, it may be dragged Go to the screen. Multi-type and dynamic series make procedures to operate correctly, even if the compiler knows that this parameter is a "shape", I don't know what shape it is. We researched the "pick_and_drag (share *)" function mentioned just now compiled on Tuesday, to Wednesday, you plan to add a hexagon.
It sounds strange, but pick_and_drag () can still handle this hexagon, even when pick_and_drag () compiles when the six-sided shape does not exist! (If you do C how to do it, it will never be amazed - but it is still very convenient!) ====================== ================== Q5: Who is using C ? A lot of many companies and government departments. Quite more. Statistics: When you are reading this FAQ text, there are 5 people who are C programmers. ================================================ Q6: Is there any C standardization plan? ? Yes; ANSI (US) and ISO (International) organizations are working closely. The ANSI-C committee is called "x3j16", and the ISO C standard group is called "WG21". These people are included in the standard process of ANSI / ISO C : AT & T, IBM, DEC, HP, Sun, MS, Borland, Zortech, Apple, OSF, etc. There are about 70 people at a time, they come from the United States, Britain, Japanese, Germany, Sweden, Denmark, France ... (they all have "regional" committees, dispatching official representatives and dominates the "regional" meeting). ==============================================================: Where is the latest ANSI- C standard draft? ISO Committee Draft for C and ANSI C Draft (files will be available for public remitts) can be obtained this: http://www.cygnus.com/~mrs/wp-draft
You can also get the version of PostScript and Adobe Acrobat:
FTP: //RESEARCH.ATT.com/dist/stdc /wp
Also get the version of HTML and ASCII:
ftp://ftp.cygnus.com/pub/g
You can also get written version: x3 Secretariat1250 Eye Street NWSUITE 200WASHINGTON, DC 20005202-626-5738 You can also use email: lbarra@itic.nw.dc.us (Lynn Barra) to request the latest "Draft Proposed American National National National National National National National National National Naz Standard for Informationsystems - Programming Language C , file number CD14882. It is usually delivered with a 2-date Fedex (in the United States), so it will soon be received. ================================================= q8: C is back to ANSI-C backtrack ? Almost. C is compatible with C, but it is not more compatible. In fact, the main difference is that the C requirements function prototype: "F ()" is declared a function (in C, "F ()" and "f (...) are the same). There are still some subtle differences like SizeOf ('x') in C , but it is equivalent to Sizeof (int) in C. Moreover, C directly uses the volume of the structure as a type of other name, but c will need to add a "struct Fred Fred" that is still used, but it is cumbersome in C . of). ================================================= q9: How long can I learn C ? Like Paradigm Shift, successfully taught the standard "Short-term Course", compressed university semester to a week. However, the true proficiency is actually experienced: there is no thing to replace the time. The designation of the need to do it is necessary because they can "solidify their ideas". About 6-12 months can always use C / OOP, if there is a master, the time is short; if there is no "good" universal C object link library, it will take time longer. If you want to be a professional master, it takes about 3 years. Some people can't do it at all. Unless you are a material that is made, you can't do anything. "The scorpion can be taught" The minimum requirements are: You must "feel this is not yesterday." The minimum requirements of "driving" are: You are willing to invest more time energy (change the way to think, "Model Transfer Paradigm Shift is far more difficult than in the new things).
========================= ■ □ Section 4: C foundation ================ ========= Q10: What is the class? The cornerstone of the object-oriented system. The category is used to define the data type (Data type), just like the Struct of C. In terms of information science terms, a type contains a set of states, as well as operational behavior (operations) between states. So "int" is a "type" because it has a set of states, as well as operational behavior such as "plus two integers", "integer multiplication" and so on. Similarly, "Category" provides a set of (usually public) operations, and a set of (usually non-public) data domains to represent abstract values owned by the case. From a C perspective, the category is a Struct that is preset as "private". Taking "int" wants to be a category, it has "Operator " and other operational behaviors (Method). ======================================================== q11: What is object? A piece is present in a generic storage space. After declaring "INT I;", we call "I is an object of INT type". In C / OOP, "Item" usually refers to "an instance of a class", so the category defines a number of items (case). ================================================= q12: What is the reference? An object of "alias" (alias, another name).
References are commonly used for part-by-reference: void swap (int & INT & J) {INT TMP = i; i = j; j = tmp;} main () {int x, y; // ... swap (x, y);} Here "i" and "j" are the "x" and "y" alias, respectively, in other words, "i" is "x" - not A pointer to "X", nor "x" of the replica of this value, and its indefinite is "X" itself. Any actions you do for "I" will be reflected on "X"; vice versa. From the bottom floor, refer to the most common pointer, its effect is a bit like the "pass-by-pointer" in C, but "&" is replaced by the caller. The caller is, you also want to delete all "*" operations. ======================================================== q13: If a value is set to the reference meeting how about it? The objects referred to by the referencer (Referrent, the reference "). Remember: "Reference" is "Reference", so the reference will be changed to the referencer ("Reference" is the left value "LVALUE" "Reference" [Lvalue "in the setting statement) . Further, we also allow reference to be returned. Such a subsource call can be placed on the left side of the setting, which is useful for the operation of the operation operation. ============================================================================================================================================================================================================================================================================================= Object? There is no way. Unlike pointers, once the reference is set to an object, it cannot be changed to other objects. "Reference" itself is not an object (it doesn't have the address yourself; "Refer to the address" will only get the address of the reference: Remember: "Reference" is "Reference"). It is impossible to separate the "reference" and "reference". ================================================= q15: When should I use, when? Also use the pointer? Optional, use the reference; if necessary, use the pointer.