Home > Backend Development > C#.Net Tutorial > C language quick learning and getting started guide

C language quick learning and getting started guide

伊谢尔伦
Release: 2016-11-26 09:05:48
Original
1233 people have browsed it

Some people think that now is the era of java and .net, who still needs C and assembly? Who knows, Java and .net are built on software, and they are systems established to monopolize the market. It is like digging a pit with a golden wall and asking you to jump down. You still think you are standing on the shoulders of giants. , in fact, became the frog in the pit. To become a real programmer, and to become a master programmer, you must start from the machine, from CPU to operating system, and then to the software system. The realm of a master is the mirror after enlightenment. If the software design is superb, I am the program. The program is me.

Onlooker Li Si said: This person is stupid! I use the mouse to drag a few controls, and it becomes a xxx management system. You might not be able to write it in C language for a year! Well, I have to admit that those who say this are already slaves of mS. I don’t know anything else. MFC itself is a closed architecture. If you start learning from MFC, you will only form a closed thinking mode, because MS hopes that many people will only learn superficial things and not become masters, so it strongly recommends so-called visual program development tools. There are really many people who are willing to be fooled by it and finally lose their way. Let's say he can't handle the program. He can do it, but if the program is more complicated and a problem occurs, he won't be able to figure out where the problem is. It's unclear anyway!

Liang Zhaoxin, a great guy, he said: "I just don't understand, how to write a program with a mouse? In my company, the expert's keyboard beeps constantly and the mouse beeps occasionally, while the novice's mouse beeps The keyboard rings occasionally, and the difference in their salaries is not more than double! "

C language is the basis of major operating systems. The kernels of Unix, Linux, and Windows are all developed in C language, ( In some places, it is developed mixed with assembly language). Didn’t you see that Windows API is an interface for C language functions? The vast majority of Unix/Linux applications are developed in C language; there are not many Windows applications developed with pure API, and most of them rely on some kind of Application Framework, such as the so-called VC++, which actually refers to VCIDE+C++ language+MFC (now the focus has shifted to ATL, WTL), but underlying software such as Windows services, networks, and drivers are still developed in C language. Compilers for various languages, including the Java virtual machine, are developed in C language. Various embedded devices, such as mobile phones and PDAs, are also developed in C language.

The first thing to put in your bag and move forward with you is the "standardized format". Therefore, a standardized format is the basis for getting started. So what does the format of this specification include? Quite a few, you have to persevere to do it! Long identifier naming, code indentation, a pair of curly braces not exceeding one screen, etc.

The second thing to pack is patience. As the saying goes, if a worker wants to do his job well, he must first sharpen his tools. To be successful, it is impossible without a relatively mundane process. This not only means that you have to be patient and step-by-step in the learning process, but it also talks about another important aspect: the adjustment process. Debugging is an important aspect in the process of writing a program. If someone can write a program in one go, he is awesome, and he is a big cow. Not only a big cow, but also the green bull that I ride on. Mortals are unethical! Debugging is a process that every program must go through.

The first step, what should you learn? Dog beating stick method! Haha

A great man once said: "Repetition of authority is the only way to maturity." This is the approach of standing on the shoulders of giants. The first thing people who practice martial arts must learn are various routines, such as the evil sword. Only then can we master it and start a school; we should also learn to write programs in this way. This is a shortcut that can help you go further.

Read a book, read a good book! What is written in the book is written by predecessors with decades of experience. Reading ten books is equivalent to absorbing decades of skills from predecessors, and your internal strength will also rapidly increase by a Jiazi. :) Of course, you must read good books. Only good books are nutritious. You must read thousands of books and program like a god; boring reading is very depressing and can easily turn into a fossil! Nowadays, many books use source code to explain problems. The source code is like animation or slideshow, showing you the moves in the book one by one. This step of manual input cannot be omitted. Nowadays, many books have supporting source codes. Many students or adults are clever when they are studying. They directly copy the source code, compile and run it. Hoho, this is ineffective.

TC has at least one benefit: it can exercise our habit of using key combinations and our habit of using keyboard programming.

1. You must read good books, otherwise it is better not to read

Kernighan and Ritchie's "TheC Programming Language" (Chinese translation: "C Programming Language") can be called a classic among classics. However, many contents in the old version are outdated and far from the current standard C language. Everyone must read the latest one. version, otherwise it is better not to watch it. In addition, even the most classic and authoritative book cannot cover everything, so it is necessary to keep a "C Language Reference Manual" on hand. The "C Language Reference Manual" is the "CReferenceManual", which is a detailed description of the C language standard, including details of most C standard library functions. It can be regarded as the best standard C language reference book. By the way, the latest "C Programming Language" is revised according to the C89 standard, while the "C Language Reference Manual" describes the C99 standard. There may be some differences between the two. It is recommended to study according to the C99 standard. There is also a book "C and Pointers", which is also quite well written. The English name is "Pointerson C". It particularly emphasizes the importance of pointers, which is a feature of this book. However, this book is not very suitable for beginners. If you have ever learned C language and have some basic knowledge of C language but are not very solid, then you can try this book. I believe that as long as you understand pointers, C language will no longer be mysterious.

If you have finished reading a C language textbook and want to go further, then there are two books you must read. The first is "CTraps and Pitfalls" (Chinese translation: "C Traps and Pitfalls"), a very thin booklet with very, very interesting content. It should be noted that this book was written more than twenty years ago, and many of the shortcomings of the C language mentioned in it have been improved, but it is not a bad thing to understand some history. Then you can challenge "Expert C Programming" (Chinese translation: "Expert C Programming"). As the name of the book suggests, this book is quite difficult. Once you read it carefully and understand it thoroughly, you can confidently and boldly write "Proficient in C Programming" on your resume. C language".

Remember one principle: don’t read books you don’t understand yet, it’s a waste of life. If you can't understand it, you must be missing some essential basic knowledge. At this point, you need to carefully analyze what content you need to add, and then go to the bookstore to find books about these contents. Only by completing the basic knowledge and then coming back to learn will you truly get twice the result with half the effort.

Second, Unix/Linux or Windows, this is a big question

Different programming environments will create programmers with different thinking. Most Windows programmers rely on integrated development environments, such as Visual Studio, while Unix programmers prefer Makefiles and consoles. Obviously, the integrated development environment is easier to use. To learn C language on Windows, you only need to press a few basic Visual C++ toolbar buttons to start writing Hello, World!, while under Unix, you need some console operations. basic knowledge. Some people may think that the Unix environment is simpler, but the power of habit is great.

So I suggest that beginners should use Visual C++ 6.0 (not Visual C++.NET) or DevC++ as the main learning environment, and don’t get too entangled in the IDE usage skills, because in the future you must switch to the Unix environment . Visual C++ 6.0 is easy to use and intuitive to debug, but its default compiler does not support the C standard well, while DevC++ uses the gcc compiler and supports the C99 standard well. By the way, many university C language courses still use TurboC2.0 as the experimental environment. This is quite undesirable. The first reason is that TC2.0 has almost no support for the C standard. The second reason is that TC2.0 compiles The program is 16-bit, which will cause great trouble in understanding 32-bit programs in the future (of course, using things like djgpp can make TC2.0 compile 32-bit programs, but that is too complicated).

After you finish studying a C language textbook, you must turn to the Unix platform to continue learning. Almost all advanced C language tutorials are based on the Unix platform (such as "C Expert Programming"). The transformation process is painful. You need to face a variety of complicated commands, which are completely different from the way of thinking on the Windows platform, but the pain is worth it. Unix and C are symbiotic, and the way of thinking and habits of Unix are more in line with the way of thinking and habits of C language. Under Unix, you can find countless excellent source codes for you to read. You can easily view the online manual of a certain library function, and you can also see the best coding style (when it comes to coding style, I will write a dedicated (described in detail in this article).

It boils down to one sentence: For beginners to learn C language, it is recommended to use Windows system and integrated development environment. When preparing to work hard to become a "master", please turn to the Unix platform first.

3. Everything is ready, you are Dongfeng

The book has been selected, the environment configuration is completed, as the saying goes, everything is ready, all you need is your own efforts. Please start from the preface of the book and read the textbook at hand carefully. Many people like to start reading directly from the first chapter. This is a wrong approach. The preface is the author's general introduction to the entire book. The author will generally tell you what foundation you need to read the book smoothly, which can help you check whether you already have the basic knowledge. After reading the preface, you should also browse the table of contents to understand the overall structure of the book, and arrange a study plan for yourself.

After the examples are exercises. I recommend beginners to do all the exercises independently.

Maybe you think learning this way is too slow, but it’s not. If you study carefully, you don't have to look back. When you learn later and find out that you didn't understand it before, then the gain is really not worth the loss. Generally speaking, after reading the entire book, you should complete thousands or even tens of thousands of lines of code. Whether you copy the book exactly or write it on your own whim, it will be an asset for you to continue learning in the future. Take myself as an example. When I read "Windows Core Programming" (I only read 3/4 of the content), in addition to copying the code in the book, I also wrote many examples myself, with a total of 5574 lines (statistics using the wc tool under Unix ), after many days, I can no longer remember the system programming of Windows, but as long as I take a few minutes to dig out the previous code and look at it, I will understand it again. This is the saying that a good memory is worse than a bad writing.

Read carefully, copy the source code carefully, complete the exercises independently and conduct further experiments, and finally leave all the code behind to become your own experience and wealth. It is absolutely hard work, and it is definitely twice the result with half the effort. Of course, this method is only suitable for learning technologies that require proficiency. If you are not learning C language, you have to analyze the specific situation.

At the end of writing, there is still a very, very important point that was not mentioned - coding style. From the very beginning of learning, you must force yourself to imitate the best coding style. Because coding style is so important and contains too much content, I will use a dedicated article to discuss it in detail. Please pay attention to "The Programmer's Road─About Coding Style".

Pause here, what I said above is my learning style: I always have to go through some twists and turns, mess around for a few times, and then I will have a sudden enlightenment - enlightenment! I have never seen many people as stupid as me. Now I understand that I always overcomplicate things at the beginning, causing an embarrassing situation like a dog biting a hedgehog. However, there are unexpected gains! But I don’t recommend that you imitate this style, at least not when chasing a girlfriend. Many opportunities in life lie in the moment you take over, and you can never get them back if you lose them.

Now I’m back. Later, by chance, I understood a line of code, which was a print statement. I was so excited at the time that I looked carefully at this and that. I understood a lot of things at once, as if I was caught by something in that moment. It was like being hit, and I was immediately enlightened. . . .

However, it is still the same sentence that cannot be established without destruction and cannot be stopped. Just like now that I have a computer, I spend all day soaking in the ocean of the Internet and feeling the fast food culture. I haven't calmed down to think about something for a long time.

When it comes to C language, I think all friends who have learned it have this feeling, that is, "it makes me happy and makes me worry." Fortunately, C language is very powerful and widely used. Once mastered, , you can confidently say to others "I am a computer expert!", and it will be easy to learn other languages ​​by yourself in the future. The worry is that C language is as profound as "Shaolin Kung Fu" and too difficult to learn. In fact, the author believes that C language is not "difficult". As long as you can clarify your ideas and master its essence, then self-learning C language is very easy and endless fun. Today I will talk with you about how to learn C language or what aspects should be started in learning C language.

From my personal experience, no matter which language you learn, you should first understand the background of the language you are learning, or its development history. C language is a kind of high-level programming language, and its predecessor is "ALGOL". Its founders were Brown W. Carnihan and Dennis M. Leach. When the C language came out, it had great limitations because it could only be used on UNIX systems. However, with the advancement of science and technology and the development of the computer industry, C language gradually separated from UNIX. In 1987, the American Standards Institute formulated the international standard for C language, referred to as "ANSIC". Since then, it has become a widely used programming language. C language has many advantages, the main ones are as follows:

It has the advantages of both high-level and low-level languages ​​and is an intermediate language.

It is a structured programming language and is very suitable for structured programming.

There are rich data types, operators and functions to choose from.

Work directly with memory, making it easy and simple to modify and edit other programs and documents.

How to learn C language well? If you want to get started as soon as possible, you must master the characteristics of computers. The characteristics of computers include:

Computers are very demanding in how they deal with problems, and tell them all possibilities.

Computers require that the description of the program be precise and unambiguous.

Computer programming requires a strong overall perspective and logic, and there is no problem of ups and downs.

The computer requires its owner to consider the problem comprehensively, tell it all possible situations and solutions, learn to be calm and have a stable mentality, and the sentences used for communication must be clear and have a single meaning.

How can I learn C language quickly and get through the running-in period faster? Memorizing and understanding the grammatical rules of C language is of course indispensable. In addition, you should also pay attention to the following aspects:

Balance your mentality. Although you cannot achieve the level of "not being happy with things and not being sad with yourself", at least don't be impetuous, don't be in a hurry for success, haste makes waste.

Cultivate your own overall awareness, so that you can be both small and big without the inside.

Strictly design the program according to the program design process. Don’t jump around and let your imagination run wild. There is no rule without rules.

Strive to improve your overall quality. Program is the expression form of human thinking and a combination of human thinking and language in dealing with problems. The extent to which you are objectively aware is directly proportional to the knowledge you have. If you don't understand the problem you're dealing with and don't know how to deal with it, you won't be able to write a program.

Learn to communicate, communicate more, and complement each other. Teamwork is also very important.


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template