Current location - Music Encyclopedia - Dating - How can I learn C well?
How can I learn C well?
I hope it is useful to you, an article I like very much! ! ! !

Six-step learning method of C language programming introduction

Is C easy to use? Can I learn well?

If you can successfully run the following Hello World program, you have already started.

# contains "stdio.h"

int main()

{

printf(“Hello World”);

Returns 0;

}

Seeing this, you may have doubts: C language is powerful, so it's not that simple for a beginner to run such a simple program, is it?

Hello World program is simple, but "sparrow is small and complete", it has the basic characteristics of C program, even the most powerful C program has these basic characteristics, so you can get started by running this program.

Can you learn well after getting started?

A toddler, if he can get rid of his parents' support and take the first step successfully, will you doubt whether he can learn to walk, even though he will stumble for a long time to come? On the contrary, if children are always afraid of wrestling and never practice walking again, the consequences can be imagined.

After getting started, we should cultivate interest in learning C language. If you are interested, even if you are tired and difficult to learn in the eyes of others, you will be happy to learn. Just like playing games, you will feel for yourself without the teacher's instruction, and you won't feel tired playing games all night. Besides, you will often exchange your experience and experience in playing games with your classmates. Will the skills of playing games be improved? Isn't that what learning C language is all about? Cultivate your interest in learning C language. Interest is the best teacher for you to learn C language. If you are interested, make friends with some C language lovers around you, study together (the purpose is to eliminate your loneliness in learning), and often exchange ideas and experiences in learning C language (sometimes, if you don't understand the problem, a casual sentence from others will open your eyes and broaden your horizons. If you do this,

A word for beginners of C language: First of all, believe that you have the ability to learn C language well, and then show this ability at all costs, and you will succeed. Do anything, don't you

How to learn C language after the fear of learning C language is relieved?

The following is my experience in learning programming and teaching (applicable to all programming languages), and combined with the C language software I developed, I will introduce the learning method of C language, hoping to help beginners of C language.

Novices encounter the most confusion: they can understand the examples in class and in books, but they don't know how to do it when they do it themselves. There are three reasons for this phenomenon:

First, the so-called understanding is only superficial grammatical knowledge, and the program or software we write controls the process of the program according to the actual needs of solving problems. If you don't have a deep understanding of the execution process (or process) of statements in C language, how to write programs to solve these practical problems?

Second, using C language programming to solve practical problems requires not only the programming knowledge of C language, but also relevant professional knowledge. For example, if you don't know the area formula of a rectangle, even if you learn C language well, you can't program the area of a rectangle.

Thirdly, C language programming is a practical course. You can't learn C language without practicing optics on paper. For example, everyone has seen a wonderful bicycle acrobatic performance. If you have never ridden a bike, listen to the coach explain the relevant knowledge, rules and skills, let alone perform on stage or go on the road.

The cause of the problem is clear, so how to study? Please watch the six steps of learning C language.

Special reminder: Before using this method, you must read the relevant contents of C language, grasp the main points of relevant knowledge initially, and then learn by the following methods, which can achieve the purpose of understanding, consolidating and improving the knowledge of C language and improving the ability of program mode.

The first step, confirmatory exercise

This step requires inputting the program as it is according to the program examples in the textbook, and running the program to see if it is correct. In this step, you can basically master the use of C programming software (including creating, opening, saving and closing C programs, and skillfully inputting and editing C programs; Memorize the knowledge points in the new chapter and develop a good C language programming style. Click here to view the programming style of C language.

Using the software "Turbo C/C++ for Windows Comprehensive Experiment and Learning Environment", you can easily watch the comprehensive software "Introduction to C Language" and practice program examples. Please refer to the help section of the software for specific usage.

Beginners are most likely to make mistakes:

1, there is no distinction between the number 1 and the letter l in the textbook, and the difference between the letter o and the number 0 leads to the error of undefined variables. Another error-prone point is to put commas and semicolons in English; Parentheses () double quotes ""Chinese input commas and semicolons; Parentheses () and double quotes ""will cause illegal character errors.

2. Beginners of C language are prone to make grammatical mistakes: using undefined variables and markers (variables, constants, arrays, functions, etc.). ) is case-insensitive, omitting ";" , "{"and "}", "("and ")" do not match, the format of control statements (selection, branch and loop) is incorrect, there is no corresponding header file when calling library functions, undeclared custom functions are called, actual parameters do not match when calling functions, and the array boundary is out of bounds.

3. Modify the syntax errors in C language should pay attention to the following two points:

(1), because the syntax of C language is free and flexible, the location of the error message is not particularly accurate. For example, when an error is prompted on line 10, if no error is found on line 10, the error will be found and modified from line 10.

(2) A statement error may produce several error messages. As long as this error is corrected, other errors will disappear. Special note: Generally speaking, the first error message can best reflect the location and type of the error, so when debugging the program, it must be modified according to the first error message. Run the program immediately after modification. If there are still many errors, modify them one by one, that is, run the program every time you modify an error.

Step 2: Draw a gourd ladle.

On the basis of the C program input in the first step, make tentative modifications, run the program, see what changes have taken place in the program results, analyze the reasons for the changes, and deepen the understanding of new knowledge points. In fact, this is synchronous with the first step, that is, to realize "input" to deepen the memory of knowledge and "modify" to deepen the understanding of knowledge. Memory and understanding complement each other and promote each other.

Take the simplest Hello World for example! procedure

# contains "stdio.h"

int main()

{

printf("Hello World! \ n ");

Returns 0;

}

Hit a target/mark

printf("Hello World! \ n ");

Hello, the world is here! Change it to your name, run the program and see what changes.

Another example is the program for calculating the sum of 1+2+3 ...+100.

# include & ltstdio.h & gt

Master ()

{

int i,sum = 0;

for(I = 1; I<= 100; i++)

{

sum = sum+I;

}

printf("sum=%d\n ",sum);

}

for(I = 1; I<= 100; I++) From 100 to 50, run the program and see what happens.

for(I = 1; I<= 100; I++ in i++ is changed to i=i+2. Run the program and see what has changed.

Finding out the reasons for the change of program results will deepen the understanding of C statement.

The third step is to see if the programs in the first two steps can be correctly input and run without looking at the textbooks.

This step requires that you don't read the textbook, even if the program can't run, see if it can be corrected so that it can run correctly. The purpose is to further strengthen the memory and understanding of the first two steps.

Step 4: Enhance the debugging ability of the program.

In the textbook "Turbo C/C++ for Windows Integrated Experiment and Learning Environment", every chapter has mistakes that beginners of C language are easy to make. According to the type of error, change the correct program in the textbook into the wrong program, run the program, see the error message prompt that appears, write down the error message, then change the program into the right one and run the program. This kind of repeated modification will let us learn the causes of errors in C language programs and the ability to modify errors.

Note: only change one place at a time, the purpose is to show the real reason of the error, avoid changing more than one place at a time, and find out the real reason of the error, remember! ! ! !

Note: When debugging the program on the computer, you should take a notebook, write down the English error prompt information and the methods to solve the error problem, accumulate the debugging experience of the program, and avoid making the same mistakes in programming. Remember! ! ! ! .

For example, put a statement in a Hello World program.

printf("Hello World! \ n ");

Medium; Change Chinese into semicolon;

Run the program and see what happens.

The form of error message in C language: (The following example is the error message of Turobo C2.0, as shown in figure 1).

Error file name line number colon error content

↓ ↓ ↓ ↓ ↓

Error e: \ wintc \ wintc \ frost.c5: function call is missing in function main)

The form of error message in C language: (The following example is Visual C++6.0 error message, as shown in Figure 2)

File name line number colon error code colon error content

↓ ↓ ↓ ↓ ↓ ↓

E:\wintc\wintc\frist.c (5): Error C2 143: Syntax error: in ";" Missing')' before.

This software integrates two compilers, Visual C++6.0 and Turbo c 2.0, which are widely used in colleges and universities, and supports the editing, compiling and debugging of C, Standard C, C++, Standard C++ and WINDOWS C programs. The software intelligently selects the compiler according to the type of user input program, without user intervention.

Debugging the program is a very practical thing, and it is useless to talk on paper. Just like a swimmer who only listens to the coach's explanation and demonstration, he will never learn to swim unless he practices in the water.

Even a good programmer can make mistakes when writing programs, which may be the lowest grammatical mistakes, but he can quickly find mistakes and correct them, while we C language beginners don't know what mistakes have happened and how to correct them. This is the difference.

The fifth step is to learn typical C language programs and improve the programming ability.

After the above study, we have learned the flow of various statements in C language (that is, how the computer executes these statements), and then we can learn the classic programs written by others in C language, understand how others solve problems, learn problem-solving methods and programming skills, and improve our programming ability.

There are more than 50 typical source programs in the software. Study its implementation method and improve your programming ability.

The sixth step is to learn the order of curriculum design and improve the ability of programming and debugging large programs in C language.

The purpose of C language course design is to make students comprehensively use C language knowledge, solve some practical problems, improve the programming and debugging ability of larger programs, and lay a solid foundation for further software development.

There are four annotated course design source programs in the software.

Introduction to C language in Turbo C/C++ for windows integrated experiment and learning environment.

Click to download the software materials.

Software data download

C, are you studious?

C, are you studious? Novices often ask this question. The answer is simple. If you are interested in C language and have a strong desire to learn it, you will learn it easily. If you are not interested, you can't even learn simple knowledge.

Imagine how many schools teach students to play games now. The answer is no, but many students learn to play games, and they often exchange their experiences in playing games.

If you are interested in C language, why not apply the experience of learning to play games to learning C language? If so, is C still difficult to learn?

Finally, a word to beginners of C language: First of all, believe that you have the ability to learn C language well, and then show this ability at all costs, and you will certainly succeed. Do anything, don't you

Interest is the biggest motivation to learn C language, and the learning method points out the direction of your efforts and makes you get twice the result with half the effort. If you think it is helpful, please reply and let more friends know. Thank you for your support! ! !

____________________________________________________________________________

22 steps to becoming a master programmer

Through foam

1. The colorful college life will make you unforgettable all your life, but there are many kinds of unforgettable. You can learn a lot and then forget. You will forget because you have learned nothing!

Computer major is a very boring major, but if you come, you will find it safe. As long as you study hard, you will find it interesting.

3. Remember: Tall buildings rise from the ground! Fundamentals are very important, especially professional basic courses. Only by laying a good foundation can we learn more.

C language is the foundation and very important. If you can't learn C language well, you can't learn any advanced language well.

5.C language and C++ language are two different things. Just like the giant panda and the little panda, but with similar names.

6. Please study the specialized courses "Data Structure" and "Computer Organization Principle" first. Don't use VC to read from the beginning. You don't even know the direction of the object. Reading VC is useless.

7. After having a certain understanding of programming, you can learn C++. (It's C++, not VC. These two are two different things. C++ is a language, and VC tutorial is to explain how to use MFC.

Class library, learning VC should be based on a full understanding of C++. You can't learn C++ language by reading VC books. )

8. The secret of learning programming is: programming, programming and reprogramming;

9. study every major course carefully, which will be your future job.

10. In the school lab, no one will scold you even if you do 10,000 wrong programs. If you are in the company, try it! So I go to the lab to use the computer more often. Now I make a lot of mistakes, and I will make fewer mistakes after graduation.

Yes

1 1. From now on, we should develop the good habit of writing programs.

12. Don't leave out any exercises in the book-please finish them all and write down your thoughts.

13. You will buy a lot of reference books, so please input the program examples in the book into the computer for practice, even if there is source code in the supporting CD.

14.VC,C#。 NET will be out of date, but what will not be out of date is data structure and excellent algorithm!

15. Remember: you hate books when you use them. Don't let this happen to you. You have enough time and conditions to study more at school. You can read more original works if you can.

When translating a book, the translator will unconsciously put his own ideas into the book, and the book will become like a chicken rib!

16. I still emphasize listening to professional courses carefully, because some courses are like data structure, compilation principle, operating system and so on. This kind of class teacher can tell you what you can understand in one minute.

You have to watch it for months, and some even don't understand it for years.

17. Seize various practical opportunities in the school and accumulate experience for yourself. In employment, experience is more useful than anything.

18. Go to the library more often. Every school library has many good books waiting for you to read!

19. Programming is not a technical activity, but a manual activity.

20. If you decide to be an excellent programmer, please give up games, unless you are a genius who can write good programs by playing games every day!

2 1. You should have enough toughness and perseverance! An expert asked a question to test your toughness and perseverance: find a list of prime numbers within 10000, copy them all down, and then check them three times.

If you can finish the work without interruption, you can meet this requirement.

22. Find your own learning methods. Don't blindly follow other people's methods, what suits you is the best!

_____________________________________________________________________________

Eight mysteries of becoming a master programmer

Excerpt from: China Computer Education News Author: Unknown.

I have been doing software for ten years unconsciously. I have both the joy of success and the pain of failure, but I still dare not call myself a master, because I am far from the real master in my mind. There is no shortcut to becoming a master in the world, but there are some basic principles to follow.

1, solid foundation

Data structure, discrete mathematics and compilation principle are the basis of all computer science. If you don't master them, it is difficult to write a high-level program. Everyone can write programs, but when you find it difficult to improve to a certain extent, you should think about whether to go back and learn these most basic theories. Don't learn OOP from the beginning, even if you are proficient in OOP again, you may be at a loss when you encounter some basic algorithms. Therefore, it is very necessary to read more books on basic computer theory.

2. Rich imagination

Don't stick to a fixed way of thinking. When you encounter a problem, you should think of several ways to solve it, and try ways that others have never thought of. Rich imagination is based on rich knowledge. Besides computers, I dabble in other subjects, such as astronomy, physics, mathematics and so on. Open thinking is very important for programmers.

The simplest is the best.

This may be a principle that all sciences follow. In Einstein's eyes, the complex principle of mass-energy conversion is nothing more than a simple formula: E=mc2. Simple methods are easier to understand, implement and maintain. When encountering problems, the simplest scheme should be given priority, and only when the simple scheme cannot meet the requirements, the complex scheme should be considered.

4. Don't get stuck.

When encountering obstacles, stay away from the computer for a while, look at the scenery outside the window, listen to light music and chat with friends. When I have problems, I will play games. When the brain cells in charge of games are extremely excited, the brain cells in charge of programming get a full rest. When I start working again, I will find that all those problems can be solved now.

5. Desire for answers

The development history of human natural science is a process of longing for answers, even if only a small part of the answers can be known, it is worth paying. As long as you firmly believe that you can find the answer to the question, you will devote your energy to exploration. Even if you don't get the answer in the end, you will learn a lot in the process?

6. Communicate with others more.

There must be a teacher in a threesome, and perhaps in a casual conversation with others, generate can be inspired. Get online more and see other people's views on the same issue, which will give you great inspiration.

7. Good programming style

Pay attention to form good habits, and the naming rules of indented codes and variables should always be consistent. Everyone knows how to eliminate errors in code, but they often ignore the debugging of comments. Comments are an important part of the program, which can make your code easier to understand. If the code has clearly expressed your ideas, there is no need to add comments. It's even worse if the comments are inconsistent with the code.

8. Resilience and perseverance

This is perhaps the biggest difference between a "master" and an ordinary programmer. A master is not a genius, but is tempered by countless days and nights. Success can bring us great joy, but the process is extremely boring. You might as well do a test, find a list of prime numbers within 10000, copy them all down and check them three times. If you can finish this work continuously, you can meet this requirement! !

Practice more haha