📄 page_1008.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>page_1008</title> <link rel="stylesheet" href="reset.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <table summary="top nav" border="0" width="100%"> <tr> <td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_1007.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_1008</strong></td> <td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_1009.html">next page ></a></td> </tr> <tr> <td align="left" colspan="3" style="background: #ffffff; padding: 20px;"> <table border="0" width="100%" cellpadding="0"><tr><td align="center"> <table border="0" cellpadding="2" cellspacing="0" width="100%"><tr><td align="left"></td> <td align="right"></td> </tr></table></td></tr><tr><td align="left"><p></p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="right"><font face="Times New Roman, Times, Serif" size="2" color="#FF0000">Page 1008</font></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">ReadAll聽(Inout:聽inFile;聽Out:聽outOfMem)</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table cellspacing="0" border="0" width="552" cellpadding="4"><tr><td valign="top"><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">Set聽outOfMem聽=聽FALSE<br />Set聽aPerson聽=聽new聽PersonnelData聽聽聽聽//聽Allocate聽a聽dynamic聽struct<br />Get聽a聽record聽from聽inFile聽into<br />聽聽聽the聽struct聽pointed聽to聽by聽aPerson<br />WHILE聽NOT聽EOF聽on聽inFile聽AND聽NOT聽outOfMem<br />聽聽聽Set聽ptrList[length]聽=聽aPerson聽聽聽//聽Store聽pointer聽into聽array<br />聽聽聽Increment聽length<br />聽聽聽Set聽aPerson聽=聽new聽PersonnelData聽//聽Allocate聽a聽dynamic聽struct<br />聽聽聽IF聽aPerson聽is聽NULL<br />聽聽聽聽聽聽Print聽warning聽message<br />聽聽聽聽聽聽Set聽outOfMem聽=聽TRUE<br />聽聽聽ELSE<br />聽聽聽聽聽聽Get聽a聽record聽from聽inFile聽into<br />聽聽聽聽聽聽聽聽聽the聽struct聽pointed聽to聽by聽aPerson</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table></td></tr></table><br /><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">The pseudocode step Get a record from inFile appears twice in </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">ReadAll</font><font face="Times New Roman, Times, Serif" size="3">. This step breaks down into several substeps: read the last name, check for end-of-file, read the first name, and so on. To avoid physically writing down the substeps twice, let's write a separate helper function named </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">GetRecord</font><font face="Times New Roman, Times, Serif" size="3">. In </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">GetRecord</font><font face="Times New Roman, Times, Serif" size="3">'s parameter list, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">aPerson</font><font face="Times New Roman, Times, Serif" size="3"> is a pointer to a </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">PersonnelData聽struct</font><font face="Times New Roman, Times, Serif" size="3">.</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">GetRecord聽(Inout:聽inFile;聽In:聽aPerson)</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table cellspacing="0" border="0" width="360" cellpadding="4"><tr><td valign="top"><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">Read聽aPerson->lastName聽from聽inFile<br />IF聽EOF聽on聽inFile<br />聽聽聽Return<br />Read聽aPerson->firstName聽from聽inFile<br />Read聽aPerson->address.street聽from聽inFile<br />Read聽aPerson->address.city聽from聽inFile<br />Read聽aPerson->address.state聽from聽inFile<br />Read聽aPerson->workHistory聽from聽inFile<br />Read聽aPerson->education聽from聽inFile<br />Read聽aPerson->payrollData聽from聽inFile</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table></td></tr></table><br /><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">The </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">SelSort</font><font face="Times New Roman, Times, Serif" size="3"> function is nearly the same as in Chapter 12. The original </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">SelSort</font><font face="Times New Roman, Times, Serif" size="3"> finds the minimum value in the list and swaps it with the value in the first place in the list. Then the next smallest value in the list is swapped with the value in the second place. This process continues until all the val-</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table></td></tr></table><p><font size="0"></font></p>聽 </td> </tr> <tr> <td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_1007.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_1008</strong></td> <td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_1009.html">next page ></a></td> </tr> </table> </body> </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -