c Language Training - Training book address book management system

1. The purpose and tasks of training courses
1.1 Training courses purpose
C language is a very practical course, through the study of "C Programming Language" course, students Although initial grasp of the basic concepts of the C language, structure the basic method of programming, but the actual ability to program and debug the program on the machine is still far from adequate. Therefore, "C Programming Language" course training dollars to consolidate and deepen students' understanding of the C language course in basic knowledge and mastery; students the ability to use C language basic software design, writing programming instructions as well as the ability to document the team spirit of collaboration; strengthen independent learning, data collection, hands-on programming and debugging capability, and you do not understand ask each other, or what the teacher. Thank a teacher for our help, so I benefited from this training, gain a lot. By C language training, I learned more about the C language, not just only those theories learned in textbooks, usually tedious course, personally written by their own hands, lively and interesting change, but in their own hands process, a lot of problems, to be more difficult than theory, a program when finished, there is often a lot of mistakes and can not solve, lay the foundation for subsequent learning professional courses.
1.2 Training courses task

Address book management system:
directory information includes: name, phone number, category (options are: A personal office Class B Class C business class), e-mail, analog mobile phone address book management system, mobile phone address book to be management. Functional requirements are as follows:
(1) View function: When you select this function, lists the following three options are: A personal office Class B Class C business class, when elected in a class, showing all of these data in the name and phone number ;
(2) an increase function: to enter new data, when entering a name and phone number of repeat, the repeat data entry prompts and cancel entry; when the address book information 15 exceeds the storage space is full and can no longer enter new data; new data entry can be performed automatically in ascending order entry number;
(3) modify the function: when you select a person's name, the corresponding data this person may be modified;
(4) delete function: select someone when the name, the corresponding data this person may be deleted, and automatically adjusts the number of subsequent entries;
(5) be managed with the menu;
(6) only enter the correct username and password to use this system;
(7) All content can be saved to a file. Next time you enter system information is read from the original file.
Composed of: Zhengjia Chen, Zhao Qian, Huang Can.
2. Analysis and Design
2.1 Analysis of design ideas
based on questions asked, because the address book information is stored in a file, it should provide documentation of input, output and other operations; you need to give personal information in the program, should provide a display, search, increase , delete and other operations.
2.2 Summary of design
Here Insert Picture Description

Specific functions:
1. Find:

Here Insert Picture Description

2. Increase Contact:

Here Insert Picture Description

3. Modify the function:

Here Insert Picture Description
4. Delete function:

Here Insert Picture Description

3. Test data and analysis program to run
Here Insert Picture Description
the program starts Please enter your password.
Here Insert Picture Description

密码正确开始程序。
Here Insert Picture Description
查询成员资料。
Here Insert Picture Description
增加成员信息。
Here Insert Picture Description
修改成员信息。
Here Insert Picture Description
删除成员信息。
Here Insert Picture Description
成员总名单查看。
4. 程序清单
加载函数
/加载所有记录,并且可以返回所有记录的个数/
{
FILE fp;
int i;
if((fp=fopen(“d:\person.txt”,“r”))==NULL)
{
printf("\nCannot open file\n");
return 0;
}
for(i=0;!feof(fp);i++)
fscanf(fp,"%s%s%s%s",&per[i].name,&per[i].phone,&per[i].classify,&per[i].email);
/把fp指针指向的文件中的ascii对应的字符转换成%s的类型赋值给后面的变量/
fclose(fp);
return(i);
}
主菜单函数
/菜单
/
void menu()
{
int n,w1;/变量n保存选择菜单数字,w判断输入的数字是否在功能菜单对应数字范围内/
do
{
puts("\t\t通讯录主界面\n\n");
puts("\t\t\t\t 1. 查询成员资料");
puts("\t\t\t\t 2. 增加一位成员资料");
puts("\t\t\t\t 3. 修改一位成员资料");
puts("\t\t\t\t 4. 删除一位成员资料");
puts("\t\t\t\t 5. 成员总名单查看");
puts("\t\t\t\t 6. 退出系统");
puts("\n\n\t\t
*******************************\n");
printf(“Choice your number(1-6):[ ]\b\b”);
scanf("%d",&n);
if(n<1||n>6)
{
w1=1;
getchar();
}
else w1=0;
}
while(w1==1);
switch(n)
{
case 1:chakan();break; /查看模块/
case 2:add();break; /增加模块/
case 3:xiugai();break; /修改模块/
case 4:shanchu();break; /删除模块/
case 5:xianshi();break; /显示模块/
case 6:exit(0); /退出/
}
}
5. 总结与体会
在初学C语言的一个学期后,我们进行了C语言实训阶段,尝试编写一个比较复杂的程序系统。在为期一周的时间中,我们同组的同学共同的感受是:C语言实训和平时上课所接触的程序是有很大不同的,所经受的考验和克服的困难是平时所无法比拟的。好在同组的搭档们精诚合作,分工明确,有问题共同解决,攻克了C语言实训的复杂程序。在这里,我作为其中的参与者,感触良多。
在这次实训中,我对c语言有了一个更深的了解认识,也对这个学期学的知识得到巩固,还尝试运行编程,每次运行程序成功,让我对下面的项目就充满信心。通过自己与同学合作编写程序,最终把最初的理论知识转化基本技能。一个c语言程序从编辑、编译、连接到运行,都要在一定的外部操作环境下才能进行。所谓"环境"就是所用的计算机系统硬件、软件条件,只有学会使用这些环境,才能进行程序开发工作。通过上机实验,熟练地掌握c语言开发环境,为以后真正编写计算机程序解决实际问题打下基矗同时,在今后遇到其它开发环境时就会触类旁通,很快掌握新系统的使用。
在编写程序中,真的是细节决定成败,因为不管程序的语句是多是少,但是只要有一条语句或语法不正确,就不能使程序得到所需要的结果。没能够使自己编写出来的程序等到想要的结果,意味着这是一个不理想的程序,对于本次编写来说则是失败的。
课程安排的上机实验的目的可以概括为如下几个方面:
1.加深对课堂讲授内容的理解
课堂上要讲授许多关于c语言的语法规则,听起来十分枯燥无味,也不容易记住,死记硬背是不可取的。然而要使用c语言这个工具解决实际问题,又必须掌握它。通过多次上机练习,对于语法知识有了感性的认识,加深对它的理解,在理解的基础上就会自然而然地掌握c语言的语法规定。对于一些内容自己认为在课堂上听懂了,但上机实践中会发现原来(转载自第。)理解的偏差,这是由于大部分学生是初次接触程序设计,缺乏程序设计的实践所致。
学习c语言不能停留在学习它的语法规则,而是利用学到的知识编写c语言程序,解决实际问题。即把c语言作为工具,描述解决实际问题的步骤,由计算机帮助我们解题。只有通过上机才能检验自己是否掌握c语言、自己编写的程序是否能够正确地解题。
通过上机实验来验证自己编制的程序是否正确,恐怕是大多数同学在完成老师作业时的心态。但是在程序设计领域里这是一定要克服的传统的、错误的想法。因为在这种思想支配下,可能你会想办法去"掩盖"程序中的错误,而不是尽可能多地发现程序中存在的问题。自己编好程序上机调试运行时,可能有很多你想不到的情况发生,通过解决这些问题,可以逐步提高自己对c语言的理解和程序开发能力。
2.熟悉程序开发环境、学习计算机系统的操作方法
A c language program from the editor, compile, link to run, to be carried out under the external operating environment. The so-called "environment" is used by the computer system hardware, software, conditions, only to learn to use these environments to program development work. By experiments on the machine, proficient c language development environment for the future lay the foundation. Really write computer programs to solve practical problems at the same time, in the future will face other development environments analogy, quickly master the use of the new system.
3. learning machine debugger
to complete the preparation process, by no means all is well. Do you think foolproof procedures, may actually trouble emerging machine is running. Such as the compiler detects a lot of mistakes. Sometimes the program itself no syntax errors, but also be able to run smoothly, but the operation result is obviously wrong. Compile system development environment provided by this program can not find logic errors, can only rely on their own experience on machine analysis to determine where the error is. The debugger is a tricky job for beginners to master debugging method as soon as possible is very important. Sometimes a little mistake you consume several hours of time, debugging expert at a glance where the error is.
6. References
1, edited by Tan Hao, C programming July 1991
2 Qiuzong Yan forward, from problem to program Science Press, Peking University Press, April 1999.
3, Rui Ting editor, computer two tutorials, Nankai University Press, October 1996.
4, Shuo Chen Ying, eds, C language program design course, Weapon Industry Press, September 1994.
5, Jiangzhong Qiu, eds, C language programming, Nanjing University Press, January 1998.

Guess you like

Origin blog.csdn.net/weixin_44517301/article/details/93214965