What is the difficult part of c programming

What should you pay attention to when learning C? What are its key points and difficulties?

The first difficult point C data types About C data types, it is not difficult to understand but difficult to use. This requires students to memorize the characteristics of some commonly used data types while studying (the content of the first homework question 2). The second difficult point C operators and order of operations 1. C is very rich in arithmetic functions and has far more types of operations than other programming languages. You should pay attention not only to the rules of certain operators, but also to the rules of arithmetic (precautions).2. When many different operations form a single expression, i.e., when there are multiple operators in a single equation, the order of precedence and the rules of combination of the operations are very important. The third difficult point of the C language of the three simple program structure in fact, the first two program structure of the C language is not difficult, three structures in the difficult point should be in the nested use of loops. (1) about the sequential structure of this structure of the program is relatively simple, that is, in accordance with the order of statements in order to execute the mechanism. The order of execution of the sequential structure is from top to bottom, sequential execution, so the program must also comply with this rule, otherwise your program execution results will not be right. statement is also a multi-branch selection statement, also known as a multi-switch statement, in the end, the execution of which block, depending on the switch settings, that is, the value of the expression and the constant expression matches that way, it is different from the if-else statement, which all the branches are side-by-side, the program is executed by the first branch to begin to look for, if matched, the execution of the subsequent block, followed by the execution of the The second branch, the third branch …… of the block, until you meet the break statement; if it does not match, find the next branch to match. (3) About Loop Structure: Loop structure can reduce the workload of source program repetitive writing, used to describe the problem of repeating the execution of a certain algorithm, which is the program structure that can best utilize the computer’s strengths in program design, the C language provides four kinds of loops, i.e. goto loop, while loop, do-while loop and for loop. The four loops can be used to deal with the same problem, and in general they can replace each other, but generally do not mention the use of the goto loop, so we focus on the other three kinds of loops. Commonly used three kinds of loops to learn the structure of the focus is to identify their similarities and differences, so that they can be used on different occasions, we take a good look at the book three kinds of loops in the format and order of execution, how to replace the use of, such as while the loop example, rewrite a program with the for statement, so that a better understanding of their roles. Note: In the while and do-while loops and the third statement in the for loop, it should contain the statement that tends to the end (such as i++,i–), otherwise it may become a dead loop, which is also a common mistake of beginners. Let’s discuss the similarities and differences of these three kinds of loops: while and do-while loops, the initialization of the loop variable should be done before the loop body, while for loop is done in statement 1; while and for loops are to judge the expression first, and then execute the loop body, while do-while loops are to execute the loop body first, while do-while loops are to execute the loop body first, while do-while loops are to execute the loop body first. The while loop and the for loop both execute the body of the loop before the expression, whereas the do-while loop executes the body of the loop before the expression, which means that the body of the do-while loop is executed at least once, whereas the while loop and the for loop are not necessarily executed at all. All three types of loops can be exited with a break statement and terminated with a continue statement, whereas the goto statement and if form a loop that cannot be controlled with break and continue statements. These three structures are not isolated from each other, in the loop may appear branching, sequential structure, branching may also appear in the loop, sequential structure and the loop, branching into a statement, which constitutes an element of the sequential structure, so these three structures in combination with each other, you can achieve a variety of algorithms, designed to solve the problem of the program, but if it is a very large topic, so that the program tends to be very long, repetitive structure and poor readability, therefore, we can not use break and continue statements to control the loop, and if the loop. and poor readability, so we often design C programs into a modular structure.

The shortcomings of the C language

C language is a very popular programming language, by many platforms selected, has many advantages. However, as people often say, “things are contradictory”, there must be disadvantages, in the see its advantages, do not ignore its shortcomings and defects. The following analysis is not intended to discourage people from learning C, but rather to give you a better understanding of the C language and learning.

(1) C language syntax is not too strict restrictions, program design freedom. “Restrictions” and “flexibility” are opposites, emphasizing “flexibility” will relax “restrictions”. This puts higher demands on programming in C, and programmers need to be more familiar with program design. For example, C does not check for out-of-bounds array subscripts, which can easily lead to data clutter in memory.

(2) C language has rich operators, as many as 34 kinds. The combination of rich data types and rich operators makes C a language characterized by flexibility of expression and high efficiency. However, this makes it more difficult to use C. These operators are divided into numerous priority levels, which are not easy to memorize and may be confused and cause errors.

(3) There are some syntactic limitations in C that should not exist. For example, a switch statement consists of a case structure, and after each case a break is used to jump out of the case structure, otherwise the following case will continue to be executed, which can cause errors.

(4) Many operators in C are “overloaded” with different meanings, and even some keywords have several meanings. For example, void, as the return type of a function, means that no value is returned; in a pointer declaration, it means a generic pointer type; in a parameter list, it means that there are no parameters.

C language programming technology advantages and disadvantages?

With the continuous development of Internet programming technology, most of the software development is now realized through the programming language, today we will come together to understand what are the advantages and disadvantages of C programming development technology.

Some good experiences with C language

Learn how to implement object-oriented programming in C language by reading POV-Ray source code at a time.

Learn about the clarity, cleanliness and maintainability of C code by reading GTK+ source code.

Learn how to implement Scheme parser in C by reading SIOD and Guile source code.

Write the initial version of GNOMEEye in C and tune the MicroTile rendering.

Some bad experiences with C

When I was on the Evolution team, a lot of things kept crashing. Valgrind didn’t exist back then, and in order to get Purify as a program, you needed to buy a Solaris machine.

Debugging the gnome-vfs thread deadlock problem.

Debugging Mesa to no avail.

Taking over the initial version of Nautilus-share, only to realize that free() is not actually used inside the code.

Wanting to refactor the code, but not knowing how to manage memory well.

Wanting to package the code, only to find global variables everywhere and no static functions.

But anyway, let’s talk about the things that are in Rust but not in C.

Automated resource management

Rust borrows ideas from C++, such as RAII (ResourceAcquisitionIsInitialization) and smart pointers, and adds the principle of single ownership of values, as well as providing automated decision-making resource management mechanisms.

Automation: there is no need to call free() manually. Memory is automatically freed when it’s used up, files are automatically closed when they’re used up, and mutex locks are automatically freed when they’re out of scope. If you want to encapsulate external resources, you basically just need to implement Drop as a trait. The encapsulated resource is like a part of the programming language because you don’t need to manage its lifecycle.

Decisional: the resource is created (memory allocation, initialization, opening a file, etc.) and then destroyed outside the scope. There’s no such thing as garbage collection: it’s all over when the code is executed. The life cycle of program data looks like a function call tree.

If I keep forgetting to call these methods (free/close/destroy) when writing code, or realize that previously written code has forgotten to call them, or even called them incorrectly, then I don’t want to use these methods ever again.


Vec is really a vector of elements T, not just an array of object pointers. After being compiled, it can only be used to hold objects of type T.

It would take a lot of code to do something like this in C, so I don’t want to do it anymore.

Traits aren’t just interfaces

Rust isn’t an object-oriented programming language like that; it has traits, which look like interfaces in Rust – they can be used to implement dynamic binding. If an object implements a Drawable, then it must have a draw() method.

But in any case, there’s more to traits than that.

Dependency management

Previously, implementing dependency management required:

Invoking g-config either manually or via automated tool macros.

Specifying header and library file paths.

Basically requiring humans to ensure that the correct version of the library files are installed.

In Rust, on the other hand, it’s just a matter of writing a Cargo.toml file and then specifying the versions of the dependent libraries in the file. These dependencies are automatically downloaded, or fetched from some specified place.


Unit testing in C is very difficult for the following reasons:

Internal functions are usually static. That is, they cannot be called from external files. The test program needs to either include the source files using the #include directive, or remove these static functions during testing using #ifdefs.

A Makefile file needs to be written to link the test program to some of the dependency libraries or parts of the code in it.

Need to use test frameworks and register test cases to them, and learn how to use them.


Rust’s hygienic macros avoid the problems that can be associated with C macros, such as things in the macros that can obscure identifiers in the code.Rust doesn’t require parentheses for all symbols in the macro, such as max(5+3,4).

No auto-transformations

In C, BNU found that many bugs were caused by inadvertently converting ints to shorts or chars, which doesn’t happen in Rust, which requires that transformations be shown.

No integer overflow

This needs no further explanation.

Do you find c language difficult? Why

– I thought it was pretty hard when I was learning it, but now I think it’s still okay, not very hard.

I. I think the syntax of c language is not powerful enough

I am learning python language now, c language is one of my freshman class, I didn’t feel it at that time, but now after learning python, I really found that the syntax of c language is really not powerful.

You don’t even have to specify the type of variable when using python, and python is especially convenient for handling data, strings can be sliced, but not in c, it’s very cumbersome. There are many other aspects, and I’ve basically forgotten all about c, so I can’t remember them, but it’s true that at the time this syntax feature gave me a whole headache.

2. c language syntax is complex

c language syntax is really not good to grasp, I was learning when the teacher let us program, ah really good trouble, all the variables have to be defined in advance, but also to specify the type of processing when the loop structure of a large number of parentheses, the head of a round about the faint, as well as what the pointer, arrays, and other things. In short, it is a headache to learn, because the syntax is too complex, often do not know why wrong, looking for half a day do not know how. Want to calculate a thing it, and to write a lot of, at that time the test share is super low, to now learn python finally on the hand, only to think that at that time is not my problem, that is, do not understand the c language.

II. Ways to learn c language

However, although I learned to doubt my life at that time, I still found some reasons why I couldn’t learn c language in this daily headache, and summarized some methods, which are roughly summarized as the following:

Read more books, and practice diligently

Learning to program, the most basic operation is to read a book, because the book has some basic theoretical knowledge and The most important thing is to read the book, because the book has some basic theoretical knowledge and syntax, and after reading the book, you can understand what basic elements are needed for a language. And after mastering the basic syntax, we need to practice more, exercise programming thinking, so that we can get more and more hands on.

According to the purpose of their own learning c language appropriate across some content

I am a finance major, learning python is completely to deal with data, so I will not be too entangled in the basic programming of those mathematical problems, because in fact, programming is difficult in the mathematical problems in the processing of data, rather than using any mathematical problems, as long as the syntax is right, and then use a powerful library, it can be a very important part of the program. The same applies to c language, you have to figure out why you are learning c language, if your goal is not to have a high math problem, then there is no need to waste time on the basics, mastering the basic syntax can be directly to your ultimate goal.

More with the big brother to ask for advice

Programming is the most important or to continue to learn, now there are a lot of programming on the Internet will be sent to free tutorials and some of their own program, in their own usually encountered problems can be targeted to look at, to learn from the experience of some of the programmers so that your programming ability to complete the big progress.

These are all my thoughts, and I hope they will be helpful to the subject!