Article count:1382 Read by:1966155

Account Entry

Write a C entry-level project of "Telephone Number Management System" from scratch [suitable for beginners]

Latest update time:2021-09-06
    Reads:

It is recommended to follow the official account below to learn more about Linux and drivers!

0.Preface

Last time I posted an embedded learning route, many fans asked me about introductory projects at various stages. Among them, the second stage " Socket- based Chat Room " has four step-by-step articles, and the first stage "Telephone Number Book Management" 》I also want it very much.

One bite must be arranged. For this project, Yiyijun also adopted step-by-step steps and explained step by step how this small project was written from scratch.

1. Project description

运行环境:ubuntu16.04
语言       :C语言

1) Function description

The functions of this project include simple menus, single linked lists, basic operations such as addition, deletion, modification, and search. Linked list insertion adopts tail insertion method.

2) Functions can be added on this basis in the future:

Information storage, database operations, CS/architecture remote management, etc.

3) Implementation instructions

Now we need to create a new node newstudent and insert it into the linked list through tail interpolation.

p = head;
PHONE *newstudent = (PHONE *)malloc(sizeof(PHONE));
newstudent->next = NULL;
while(head->next != NULL)
{
 head = head->next;
}

After these lines of code are executed, the results of each pointer are as follows:

 head->next = newstudent;

After executing this line of code, the results of each pointer are as follows:

head = p;

After executing this line of code, the results of each pointer are as follows: The operations of other linked lists will not be overly described.

4) Code flow chart

2. Execution results

The files are as follows:

peng@ubuntu:/mnt/hgfs/code/test$ tree .
.
├── list.c
├── main.c
└── phone.h

0 directories, 3 files

Compile and run

peng@ubuntu:/mnt/hgfs/code/test$ gcc *.c
peng@ubuntu:/mnt/hgfs/code/test$ ./a.out 

Program screenshot

Login interface: Enter the main phone management interface and add a phone entry: Display the added phone information:

3. How to read code

In order to make it easier for readers to read the code, Yiyijun created a git project for this small project, so that everyone can easily trace the records of Yiyijun's code writing for easy learning.

At the same time, git is a version management technology that must be mastered in current software development.

1. Install git

Then you need to set up your email and username

git config --global user.email 21689991@qq.com
git config --global user.name yikoupeng

Change the default submission opening software to vim

git config --global core.editor "vim"

2. Display historical modification records

Enter the following command to display all commit information.

git log

3. How to update the code to the original state?

For example, we want to switch to the original version node

git checkout 61b662ad92e8115f012f6247046eb4756a532a15

As you can see, this is my initial version, with only one main.c file. This code only has the simplest menu function, and the font color is not set.

To switch to the latest version, you can execute the following command

git checkout b3004eef8a1c7828095af1a87181d58a7230e91e

4. How to submit a commit?

For example, if we add a file header to each file, we can view the modified file content by running the following command:

git diff

Submit the new version through the following command
and then enter the following command to submit the commit

git commit

Then the following interface pops up. We can use the vim operation command to submit the commit information. The red box is the information I entered. Use git log to view it. You can see that the information we submitted has been updated.

Note that the code submitted in this way is placed in the local warehouse and has not been uploaded to the server. If it is enough for self-study, it can also be uploaded to the server. In this way, we can maintain this code simultaneously with many developers. If we are lucky, the project If you attract venture capital, you can not only become famous but also gain financial freedom as soon as possible. We would like to thank Linus very much here. It was this master who developed git, which enabled him to efficiently maintain the Linux kernel with millions of developers around the world. Git is also the first choice for version management by many software companies.

Code download method: Follow the official account: Yizu Linux Backend reply: Phone number management

- END -


Follow and reply [ 1024 ] Massive Linux information will be given away

Collection of wonderful articles
Getting started with linux
Click " Read the original text " to view more sharing, welcome to share, collect, like, and watch

Latest articles about

 
EEWorld WeChat Subscription

 
EEWorld WeChat Service Number

 
AutoDevelopers

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building,Block B, 18 Zhongguancun Street, Haidian District,Beijing, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号