I. Overall development of Project C as shown
Two. Analysis of each step
1. Requirements Document Analysis, this example with an electronic dictionary as an example
List each requirement and every feature of each requirement, and summarize it into a single table.
2. Design data structure
Design data structure, that is, to determine the type of abstract data, data storage methods, first think of multiple scenarios, and then compare the pros and cons of each scheme
1 /*2 Scenario 13 using a three-dimensional array, 110000 is the number of words, 2 bits per word corresponds to 2 rows, and 100 represents the number of characters each row can store.4 because of the maximum stack space of 1M, this method is not possible, and consumes CPU resources5 word[i][2][100] Represents a word and an explanation6 */7 Charword[110000][2][ -];//8 /*9 Scenario 2Ten use a structure to represent a word, key to store words, trans storage One all words are stored in a dynamic array of malloc allocations, and each word is interpreted differently because of the length of each word . A so the length of the key is too small to meet the demand, too large to create a waste of storage space - */ - structword{ the Charkey[ -];//Word - Chartrans[ -];//explanation of the word correspondence - }; - /* + Programme III - use a struct, but a member is a pointer that allocates memory based on the actual size of the word and explanation, and the memory footprint is small + Cons: Explanations are not detailed enough because a word corresponds to multiple interpretations A */ at structword{ - Char*key;//the word pointer, pointing to a malloc allocated memory - Char*trans;//Explanatory pointers - }; - /* - Scenario Four in working with structural bodies - */ to structword{ + Char*key;//the word pointer, pointing to a malloc allocated memory - intCount_trans;//number of interpretations per word the Char**trans;//array of character pointers storing explanations *};
3. Draw the program overall flow chart according to demand
4. Analyze the storage structure of the data type, such as
5. Defining Common variables
1 /********* defining common global variables *****************/2 /*3 a new name for the struct type: WORD4 */5typedefstructWORD SWORD;6 /********* struct pointer, pointing to the word bank structure Array * * * **/7SWORD *DICT;8 /*********** text Thesaurus file name *********************/9 Char*dicttxtname ="Dict.txt";Ten /*********** binary Thesaurus file name *********************/ One Char*dictbitname ="Dict.dat"; A /************ number of thesaurus, structure array length ***************/ - intLength
6. Due to the limited time and size of the essay, the remaining five steps see the late essay
C Language Project development process