Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

C language project development process

2025-03-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

I. c the overall development of the project is shown in the following figure

two。 The analysis of each step

1. Requirements document analysis, this example takes an electronic dictionary as an example

List each requirement and each feature of each requirement and summarize it into a table.

two。 Design data structure

Design the data structure, that is, determine the abstract data type and the way the data is stored, first come up with several schemes, and then compare the advantages and disadvantages of each scheme.

1 / * 2 Scheme 1 3 uses a three-dimensional array, 110000 is the number of words, 2 bits correspond to 2 lines, 100 represents the number of characters that can be stored on each line, 4 because the stack space is up to 1m, so this approach is not good, and it consumes cpu resources 5 word [I] [2] [100] to represent a word and explain 6 * / 7 char word [110000] [2] [100] / / 8 / * 9 Scheme 210uses a structure to represent a word, key stores words, trans stores 11 all words are stored in a dynamic array assigned by malloc, because each word is of different length and has a different interpretation of each word, 12 so the length of key is too small to meet the demand, which leads to a waste of storage space 13 * / 14 struct WORD {15 char key; / / word 16 char trans [100] / / word corresponding interpretation 17}; 18 / * 19 scenario 3 20 uses structures, but members are pointers, allocating memory according to the actual size of the word and interpretation, memory footprint is 21% smaller: explanation is not detailed enough, because a word corresponds to multiple interpretations 22 * / 23 struct WORD {24 char * key;// word pointers to a malloc allocated memory 25 char * trans;// interpretation pointers 26} 27 / * 28 Scheme 4 29 uses structure 30 * / 31 struct WORD {32 char * key;// word pointer to an malloc allocated memory 33 int count_trans;// corresponding to the number of interpretations per word 34 char * * trans;// holds the interpreted character pointer array 35}

3. Draw the overall operation flow chart of the program according to the requirements.

4. Analyze the storage structure of the data type, as shown in the following figure

5. Define common variables

1 / * define common global variables * / 2 / * 3 give the structure type a new name: WORD 4 * / 5 typedef struct WORD SWORD; 6 / * structure pointer to the thesaurus structure array * / 7 SWORD * DICT 8 / * text thesaurus file name * / 9 char * dicttxtname = "dict.txt"; 10 / * binary thesaurus file name * / 11 char * dictbitname = "dict.dat" 12 / * number of thesaurus, length of structural array * / 13 int length

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report