Home Common Problem How to learn c language

How to learn c language

Aug 15, 2019 am 09:55 AM
c language

How to learn c language

Original title: Written for beginners of C language, teaching you how to learn C language

Written for beginners of C language If so, teach you how to learn C language

How to learn c language

Don’t be impatient when learning C language, but do it step by step. You must know that haste makes waste. Don't blindly write a lot of code. Doing so will only pile up a lot of low-level code and make you form bad coding habits. First buy this basic textbook and take a look at it so that you can have a preliminary understanding of the C language.

Recommended tutorial:C language video tutorial

If you have high-level people around you If you are a developer, then there is nothing better than asking others for advice. But as far as I know, most beginners did not receive the guidance of a senior software engineer after entering the IT industry. Instead, they were pushed to the front line after joining the company to defraud customers for their bosses. In the process, many people are struggling to pile up code and earn pitiful wages. Although I was still making poor money, I was lucky because in my first company I met the mentor who led me to the field of Unix and C language. It was his sentence "Unix and C language". "Language is a technology that you have to learn throughout your life" made me fall in love with them. It was his sentence "You have a root password, it is not as simple as you having a root password, it is more of a responsibility" (said The premise of this sentence is that I deleted other people's things after entering the SUN server with the root password, because I thought these were useless things), which gave me a very specific understanding of the word responsibility. So here I ask the readers to allow me to use some space to express my deep gratitude to my neusoft mentor yuhj. At the same time, I would also like to express my deep gratitude to my friends at CU. It can be said that you are my second mentor and I can no longer live without you.

I hope everyone is luckier than me. Friends who are not favored by the God of Luck, don’t be discouraged. Come to CU to communicate and discuss with everyone, but be careful not to ask for details when discussing on the forum. Many things cannot be explained clearly in one sentence. Others can only give you a guide. No matter how specific it is, you can only rely on your own research and pondering. Go to the essence area in your spare time and you will gain unexpected benefits.

Don’t get confused when you see English. Although I am like this too, it’s not that I can’t understand it (after all, I have received CET4 and CET6 mute English education, so I can still understand it). Man's help is the best teaching material, and many foreign forums have very clear and simple descriptions of technology. More importantly, you will see things there that you cannot see in domestic forums (computer Technology has always been passed from the West to the East. I hope that one day foreigners will come to our Chinese forum to look for technical information).

How to learn c language

There is one thing that must be learned when learning C language, and it is best to learn it at the same time. Some friends may have guessed it, yes, it is Unix. It can be said that Unix and C language have been mentioned a lot. Wherever there is Unix, there is C language. At the same time, it is precisely because of C language that Unix exists (let us first discuss the philosophical issue of chicken or egg) Come on, hit me with a tomato), some people even say that C language is designed for Unix, which shows the unusual relationship between Unix and C language. Learning Unix is ​​much easier now. In the past, Unix was run on large servers, but now with Linux (according to GNU, Linux is Linux and cannot be called Unix). You can install a set of Linux on your PC. When learning, be careful not to compare Linux and Windows when learning Linux. They are not the same. Linux will let you know what a classic is and will always let you show your ambitions in one direction. Windows will only let you play in other people's traps, and you have to change the trap from time to time. Listed below are some of my experiences in learning Unix:

 1) To learn Unix and C language, I first recommend a book "Unix Advanced Environment Programming". This book is a classic for learning Unix and C. Try to write a practice program for all the system calls mentioned in the book, and first gain a perceptual understanding of what the system calls provided to users by the Linux system are for and how to use them. System calls are functions provided by the kernel to users to apply for kernel services. For learning the Linux kernel, starting with system calls is a good way. For the learning process, you can refer to the Linux online help and information on the Internet. When you feel that it is almost done, let me give you a contact question: to implement the functions of an ftp server and client, you can completely define some application layer protocols yourself, as long as you can transfer files with simple commands.

This question allows you to practice the basic programming methods of TCP/IP and the basic methods of file operations, which will be helpful for learning the kernel file system later.

 2) When you have some understanding of the Unix system, at the same time, for most system calls (the key is the system calls about files, for the kernel of the Linux system, from the file It is relatively easy to get started with the system) and you have a clear understanding of it, I will recommend you a book "Linux Kernel Scenario Analysis". This book is a classic about the Linux kernel. The only flaw is that it does not have any information about the network subsystem. Detailed introduction to the system. You can start with the system calls of the file system, and slowly you will have a deeper understanding of Linux. At the same time, pay attention to the application of many classic methods and ideas in Linux. You will realize why Unix treats everything as a file, and everything you operate is a file operation, and you will slowly appreciate the classics of Unix.

 3) After you have some understanding of the Linux kernel, you can find a direction to develop specifically. If you want to be interested in the currently popular network programming, then I recommend you a book "Detailed Explanation of TCP/IP". This book is a classic about the TCP/IP protocol. You will learn how the TCP/IP protocol stack is implemented, why, and how the protocols at each layer work. After you finish reading this book, you can write a DOS attack program and sniffer yourself.

I put it simply. In fact, every book I mentioned is enough for you to study for a long time at least, so I hope beginners don’t be anxious and not arrogant. I believe that as long as you work hard, you will definitely become a master. .

When writing code, everyone should pay attention to developing good coding habits, style and abstraction ability.

The following is a 20-word guideline for everyone when writing code:

1) Functions should be small

Try to make the function as general as possible, with fewer lines of code. A function only completes a simple function. You can see at a glance whether there are code errors in this function. Each function is robust, then you The program is robust.

2) There should be less code

When completing a function, the less code the better if the logic is clear. Never compare who wrote more code. .

3) The algorithm should be better

When completing a function, efficiency must be considered. Currently, computers have a large amount of memory, so memory is no longer the primary consideration. However, Efficiency is still important in some special places. If you have a high-efficiency algorithm, you don’t need an inefficient algorithm. Take a look at this article. There is an excellent post about removing the spaces on both sides of a character (trim). Many people have proposed algorithms, but one algorithm is The best, the most efficient, the least code, is the best reflection of a good algorithm

4) The naming must be clear

The naming must be clear, and the most important thing is to use Chinese Predicate structure such as set_buffsize()

5) There should be more files

Try to divide a large program into multiple files, and try not to exceed 1000 for one file OK, so you can clearly know which file code is robust and which file may have hidden dangers. When checking the code, you can check certain files in a targeted manner

The above is the detailed content of How to learn c language. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

C language data structure: data representation and operation of trees and graphs C language data structure: data representation and operation of trees and graphs Apr 04, 2025 am 11:18 AM

C language data structure: The data representation of the tree and graph is a hierarchical data structure consisting of nodes. Each node contains a data element and a pointer to its child nodes. The binary tree is a special type of tree. Each node has at most two child nodes. The data represents structTreeNode{intdata;structTreeNode*left;structTreeNode*right;}; Operation creates a tree traversal tree (predecision, in-order, and later order) search tree insertion node deletes node graph is a collection of data structures, where elements are vertices, and they can be connected together through edges with right or unrighted data representing neighbors.

The truth behind the C language file operation problem The truth behind the C language file operation problem Apr 04, 2025 am 11:24 AM

The truth about file operation problems: file opening failed: insufficient permissions, wrong paths, and file occupied. Data writing failed: the buffer is full, the file is not writable, and the disk space is insufficient. Other FAQs: slow file traversal, incorrect text file encoding, and binary file reading errors.

How to output a countdown in C language How to output a countdown in C language Apr 04, 2025 am 08:54 AM

How to output a countdown in C? Answer: Use loop statements. Steps: 1. Define the variable n and store the countdown number to output; 2. Use the while loop to continuously print n until n is less than 1; 3. In the loop body, print out the value of n; 4. At the end of the loop, subtract n by 1 to output the next smaller reciprocal.

C language multithreaded programming: a beginner's guide and troubleshooting C language multithreaded programming: a beginner's guide and troubleshooting Apr 04, 2025 am 10:15 AM

C language multithreading programming guide: Creating threads: Use the pthread_create() function to specify thread ID, properties, and thread functions. Thread synchronization: Prevent data competition through mutexes, semaphores, and conditional variables. Practical case: Use multi-threading to calculate the Fibonacci number, assign tasks to multiple threads and synchronize the results. Troubleshooting: Solve problems such as program crashes, thread stop responses, and performance bottlenecks.

CS-Week 3 CS-Week 3 Apr 04, 2025 am 06:06 AM

Algorithms are the set of instructions to solve problems, and their execution speed and memory usage vary. In programming, many algorithms are based on data search and sorting. This article will introduce several data retrieval and sorting algorithms. Linear search assumes that there is an array [20,500,10,5,100,1,50] and needs to find the number 50. The linear search algorithm checks each element in the array one by one until the target value is found or the complete array is traversed. The algorithm flowchart is as follows: The pseudo-code for linear search is as follows: Check each element: If the target value is found: Return true Return false C language implementation: #include#includeintmain(void){i

C language data structure: the key role of data structures in artificial intelligence C language data structure: the key role of data structures in artificial intelligence Apr 04, 2025 am 10:45 AM

C Language Data Structure: Overview of the Key Role of Data Structure in Artificial Intelligence In the field of artificial intelligence, data structures are crucial to processing large amounts of data. Data structures provide an effective way to organize and manage data, optimize algorithms and improve program efficiency. Common data structures Commonly used data structures in C language include: arrays: a set of consecutively stored data items with the same type. Structure: A data type that organizes different types of data together and gives them a name. Linked List: A linear data structure in which data items are connected together by pointers. Stack: Data structure that follows the last-in first-out (LIFO) principle. Queue: Data structure that follows the first-in first-out (FIFO) principle. Practical case: Adjacent table in graph theory is artificial intelligence

Troubleshooting tips for processing files in C language Troubleshooting tips for processing files in C language Apr 04, 2025 am 11:15 AM

Troubleshooting Tips for C language processing files When processing files in C language, you may encounter various problems. The following are common problems and corresponding solutions: Problem 1: Cannot open the file code: FILE*fp=fopen("myfile.txt","r");if(fp==NULL){//File opening failed} Reason: File path error File does not exist without file read permission Solution: Check the file path to ensure that the file has check file permission problem 2: File reading failed code: charbuffer[100];size_tread_bytes=fread(buffer,1,siz

The concept of c language functions and their definition format The concept of c language functions and their definition format Apr 03, 2025 pm 11:33 PM

C language functions are reusable code blocks, receive parameters for processing, and return results. It is similar to the Swiss Army Knife, powerful and requires careful use. Functions include elements such as defining formats, parameters, return values, and function bodies. Advanced usage includes function pointers, recursive functions, and callback functions. Common errors are type mismatch and forgetting to declare prototypes. Debugging skills include printing variables and using a debugger. Performance optimization uses inline functions. Function design should follow the principle of single responsibility. Proficiency in C language functions can significantly improve programming efficiency and code quality.