网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
11月18日漏签0天
孙燕姿吧 关注:1,243,570贴子:117,413,073
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 1 2 下一页 尾页
  • 20回复贴,共2页
  • ,跳到 页  
<<返回孙燕姿吧
>0< 加载中...

不会贴,瞎贴试试。

  • 只看楼主
  • 收藏

  • 回复
  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include "main.h"

/*
  ==================================================
=============================
  Author: Hammer, May 2002, For www.cprogramming.com/cboard/
  File: UserInterfaceUtilities.c
  Contents: Menu structs
  ui_DisplayMenu
ui_AddNewEntry
ui_UpdateEntry
ui_AddOrUpdateEntry
ui_DeleteEntry
ui_UndeleteEntry
ui_SearchAll
ui_SearchByID
ui_DisplayAll
ui_Save
ui_PurgeDeleted
ui_ShowInfo
ui_ToggleAutoSave
ui_SetLinesPerDisplay
  ==================================================
=============================
*/

/*
  ==================================================
=============================
  The following are the structs that make up the menus.
  ==================================================
=============================
*/

static struct menu_item OptionsMenu[] = 
{
{"Auto-Save Setup", ui_ToggleAutoSave, NULL },
{"Set Lines Per Display", ui_SetLinesPerDisplay, NULL },
{ NULL, NULL, NULL }
};

static struct menu_item SearchByFieldMenu[] =
{
{ "Search By ID", ui_SearchAll, (void *)RECF_ID },
{ "Search By Name", ui_SearchAll, (void *)RECF_NAME },
{ "Search By Phone Num 1", ui_SearchAll, (void *)RECF_PHONENUM1 },
{ "Search By Phone Num 2", ui_SearchAll, (void *)RECF_PHONENUM2 },
{ "Search By Phone Num 3", ui_SearchAll, (void *)RECF_PHONENUM3 },
{ "Search By Phone Num 3", ui_SearchAll, (void *)RECF_PHONENUM3 },
{ "Search By Address Line 1", ui_SearchAll, (void *)RECF_ADDRLINE1 },
{ "Search By Address Line 2", ui_SearchAll, (void *)RECF_ADDRLINE2 },
{ "Search By Address Line 3", ui_SearchAll, (void *)RECF_ADDRLINE3 },
{ "Search By Address Line 4", ui_SearchAll, (void *)RECF_ADDRLINE4 },
{ "Search By Address Line 5", ui_SearchAll, (void *)RECF_ADDRLINE5 },
{ "Search By Email Address", ui_SearchAll, (void *)RECF_EMAILADDR },
{ "Search By Misc Field", ui_SearchAll, (void *)RECF_MISC },
{ NULL, NULL, NULL }
};

static struct menu_item SortByFieldMenu[] =
{
{ "Sort By ID", ui_SetSortBy, (void *)RECF_ID },
{ "Sort By Name", ui_SetSortBy, (void *)RECF_NAME },
{ "Sort By Phone Num 1", ui_SetSortBy, (void *)RECF_PHONENUM1 },
{ "Sort By Phone Num 2", ui_SetSortBy, (void *)RECF_PHONENUM2 },
{ "Sort By Phone Num 3", ui_SetSortBy, (void *)RECF_PHONENUM3 },
{ "Sort By Phone Num 3", ui_SetSortBy, (void *)RECF_PHONENUM3 },
{ "Sort By Address Line 1", ui_SetSortBy, (void *)RECF_ADDRLINE1 },
{ "Sort By Address Line 2", ui_SetSortBy, (void *)RECF_ADDRLINE2 },
{ "Sort By Address Line 3", ui_SetSortBy, (void *)RECF_ADDRLINE3 },
{ "Sort By Address Line 4", ui_SetSortBy, (void *)RECF_ADDRLINE4 },
{ "Sort By Address Line 5", ui_SetSortBy, (void *)RECF_ADDRLINE5 },
{ "Sort By Email Address", ui_SetSortBy, (void *)RECF_EMAILADDR },
{ "Sort By Misc Field", ui_SetSortBy, (void *)RECF_MISC },
{ NULL, NULL, NULL }
};

static struct menu_item Page2Menu[] =
{
{ "Search By Chosen Field", ui_DisplayMenu, SearchByFieldMenu },
{ "Display All Entries", ui_DisplayAll, NULL },



  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
{ "Set Sort Order", ui_DisplayMenu, SortByFieldMenu },
{ "Undelete An Entry", ui_UndeleteEntry, NULL },
{ "Save Changes", ui_Save, NULL },
{ "Purge Entries Marked For Deletion", ui_PurgeDeleted, NULL },
{ "Application Options", ui_DisplayMenu, OptionsMenu },
{ NULL, NULL, NULL }
};

struct menu_item MainMenu[] =
{
{ "Add New Entry", ui_AddNewEntry, NULL },
{ "Delete Entry", ui_DeleteEntry, NULL },
{ "Update Entry", ui_UpdateEntry, NULL },
{ "Display Entry", ui_SearchAll, (void *)RECF_ID},
{ "Search By Name", ui_SearchAll, (void *)RECF_NAME },
{ "Save Changes", ui_Save, NULL },
{ "More Options", ui_DisplayMenu, Page2Menu },
{ "Help/About", ui_ShowInfo, NULL },
{ NULL, NULL, NULL }
};

/*
  ==================================================
=============================
  Function:  ui_DisplayMenu
    Args:  Pointer to a menu to be displayed 
    Returns:  Nothing
    Purpose: Displays the menu, gets the users option and processes it.
  ==================================================
=============================
*/
void ui_DisplayMenu(void *pmenu)
{
int i, choice;
struct menu_item *menu = pmenu;
struct menu_item *item;

for (;;)
{
printf ("---> PhoneBook Menu <---\n");
for (i = 1, item = menu; item->Text != NULL; item++, i++)
{
printf("%2d %s\n", i, item->Text);
}

printf(" x Exit Menu\nEnter choice >");

if ((choice = io_GetInt(i-1)) == RC_BAD)
break;
item = menu + choice - 1;
if (item->Text == NULL) break;
(void) (*item->fptr) (item->args);
}
}

/*
  ==================================================
=============================
  Function:  ui_AddNewEntry
    Args:  None (NULL pointer)
    Returns:  Nothing
    Purpose: Caller function to process a new entry request. 
     The menu is capable of calling the next function directly,
     but I left this in to assist future developments.
  ==================================================
=============================
*/
void ui_AddNewEntry(void *Dummy)
{
ui_AddOrUpdateEntry(Dummy);
}

/*
  ==================================================
=============================
  Function:  ui_UpdateEntry
    Args:  None (NULL Pointer)
    Returns:  Nothing
    Purpose: Asks user for an ID, then calls another function to do record updates
  ==================================================
=============================
*/
void ui_UpdateEntry(void *Dummy)
{
struct Record *rec;
int choice;

if (gl_HighestID == 0)
{
printf ("No entries in the database!\n");
io_EnterToContinue();
return;
}

for (;;)
{
printf("Enter Record ID Number (1-%d, x to exit) >", gl_HighestID);
if ((choice = io_GetInt(gl_HighestID)) == RC_BAD)
return;
if ((rec = li_GetDataPtrByID(gl_AppData.MainList, choice)) == NULL)
{
printf("No such entry: %d\n", choice);
}
else break;
}

ui_AddOrUpdateEntry(rec);
}

/*
  ==================================================
=============================
  Function:  ui_AddOrUpdateEntry



2025-11-18 06:54:55
广告
不感兴趣
开通SVIP免广告
  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
    Args:  Pointer to a struct to be updated, OR NULL is request is to ADD.
    Returns:  Nothing
    Purpose: Obtains user data to complete a Record structure, then
     adds or updates a record in the list.
  ==================================================
=============================
*/
void ui_AddOrUpdateEntry(struct Record *newrec)
{
struct Record rec;
char buffer[MAXL_FIELD+1];
struct Node *tmpListPtr;

memset (&rec, 0, sizeof(struct Record));
/*
 * If newrec is not NULL, the it must be pointing to a Record struct and
 * therefore we are updating an existing record.  In this case, we show
 * the user the existing data before asking for new.  If they press <enter>
 * on a blank line, we leave the old data in place, this saves them retyping
 * each field when they are only changing one.
 */
if (newrec != NULL) 
{
rec = *newrec;
printf("(Press <Enter> on blank line to keep existing text)\nCurrent Name: %s\n", newrec->Name);
}
printf ("Enter Name (max %d chars) >", MAXL_NAME);
if (io_GetLine(buffer, MAXL_NAME+1, stdin) == 0)
{
if (newrec == NULL)
return; /* allow user to break out by entering a new record with no name */
}
else strncpy (rec.Name, buffer, MAXL_NAME+1);

if (newrec != NULL) printf("Current 1st Phone: %s\n", newrec->PhoneNum1);
printf("Enter 1st Phone (max %d chars) >", MAXL_PHONENUM);
if (io_GetLine(buffer, MAXL_PHONENUM+1, stdin) > 0)
strncpy (rec.PhoneNum1, buffer, MAXL_PHONENUM+1);

if (newrec != NULL) printf("Current 2nd Phone: %s\n", newrec->PhoneNum2);
printf("Enter 2nd Phone (max %d chars) >", MAXL_PHONENUM);
if (io_GetLine(buffer, MAXL_PHONENUM+1, stdin) > 0)
strncpy (rec.PhoneNum2, buffer, MAXL_PHONENUM+1);

if (newrec != NULL) printf("Current 3rd Phone: %s\n", newrec->PhoneNum3);
printf("Enter 3rd Phone (max %d chars) >", MAXL_PHONENUM);
if (io_GetLine(buffer, MAXL_PHONENUM+1, stdin) > 0)
strncpy (rec.PhoneNum3, buffer, MAXL_PHONENUM+1);

if (newrec != NULL) printf("Current Address Line 1: %s\n", newrec->AddrLine1);
printf("Enter Address Line 1 of 5 (max %d chars) >", MAXL_ADDR);
if (io_GetLine(buffer, MAXL_ADDR+1, stdin) > 0)
strncpy (rec.AddrLine1, buffer, MAXL_ADDR+1);

if (newrec != NULL) printf("Current Address Line 2: %s\n", newrec->AddrLine2);
printf("Enter Address Line 2 of 5 (max %d chars) >", MAXL_ADDR);
if (io_GetLine(buffer, MAXL_ADDR+1, stdin) > 0)
strncpy (rec.AddrLine2, buffer, MAXL_ADDR+1);

if (newrec != NULL) printf("Current Address Line 3: %s\n", newrec->AddrLine3);
printf("Enter Address Line 3 of 5 (max %d chars) >", MAXL_ADDR);
if (io_GetLine(buffer, MAXL_ADDR+1, stdin) > 0)
strncpy (rec.AddrLine3, buffer, MAXL_ADDR+1);

if (newrec != NULL) printf("Current Address Line 4: %s\n", newrec->AddrLine4);
printf("Enter Address Line 4 of 5 (max %d chars) >", MAXL_ADDR);
if (io_GetLine(buffer, MAXL_ADDR+1, stdin) > 0)
strncpy (rec.AddrLine4, buffer, MAXL_ADDR+1);

if (newrec != NULL) printf("Current Address Line 5: %s\n", newrec->AddrLine5);



  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
printf("Enter Address Line 5 of 5 (max %d chars) >", MAXL_ADDR);
if (io_GetLine(buffer, MAXL_ADDR+1, stdin) > 0)
strncpy (rec.AddrLine5, buffer, MAXL_ADDR+1);

if (newrec != NULL) printf("Current Email Address: %s\n", newrec->EmailAddr);
printf("Enter Email Address (max %d chars) >", MAXL_ADDR);
if (io_GetLine(buffer, MAXL_ADDR+1, stdin) > 0)
strncpy (rec.EmailAddr, buffer, MAXL_ADDR+1);

if (newrec != NULL) printf("Current Misc data: %s\n", newrec->Misc);
printf("Enter Misc Details (max %d chars) >", MAXL_MISC);
if (io_GetLine(buffer, MAXL_MISC+1, stdin) > 0)
strncpy (rec.Misc, buffer, MAXL_MISC+1);

if (newrec == NULL) {rec.ID = gl_HighestID+1; rec.Status = 0;};

/*
 * Display new/changed details for user to review
 */
printf ("Record Details Now:\n");
rec_PrintLong(&rec);

if (io_GetYesNo("Confirm Details (y/n) >") == TRUE)
{ /* User has confirmed new details, so update/add record and add to list */
if (newrec) /* updating an existing record */
{
*newrec = rec;
}
else
{ /* Adding a new record */
if ((newrec = malloc(sizeof (struct Record))) == NULL)
{
perror ("Add/Update failed on malloc");
return;
}
*newrec = rec;
if ((tmpListPtr = li_Insert (gl_AppData.MainList, newrec, rec_Compare)) == NULL)
{
printf("Error performing insert on list.  Item not addded.\n");
free(newrec); /* throw the record away */
}
else 
{
gl_AppData.MainList = tmpListPtr;
newrec->ID = gl_HighestID;
}
}
gl_AppData.DataChanged = TRUE;
if (gl_AppCfg.AutoSave) (void)io_WriteAllRecordsToFile(gl_AppData.MainList);
}

}

/*
  ==================================================
=============================
  Function:  ui_DeleteEntry
    Args:  None (NULL pointer)
    Returns:  Nothing
    Purpose: Gets an ID from the user, displays the record then marks it
     for deletion if the user agrees.  If autosave is on, the
     list will be written to disk and the record will be erased
     completely (undelete not available in this case).
  ==================================================
=============================
*/
void ui_DeleteEntry(void *Dummy)
{
struct Record *rec;
int choice;

if (gl_HighestID == 0)
{
printf ("No entries in the database!\n");
io_EnterToContinue();
return;
}

printf("Enter Record ID Number (1-%d, x to exit) >", gl_HighestID);
if ((choice = io_GetInt(gl_HighestID)) == RC_BAD)
return;
if ((rec = li_GetDataPtrByID(gl_AppData.MainList, choice)) == NULL)
{
printf("No such entry: %d\n", choice);
io_EnterToContinue();
return;
}

rec_PrintLong(rec);

if (io_GetYesNo("Confirm Delete (y/n) >") == TRUE)
{
rec->Status = rec->Status | ST_DELETED;
gl_AppData.DataChanged = TRUE;
if (gl_AppCfg.AutoSave) (void)io_WriteAllRecordsToFile(gl_AppData.MainList);
}
}

/*
  ==================================================
=============================
  Function:  ui_UndeleteEntry
    Args:  None (NULL Pointer)



  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
    Returns:  Nothing
    Purpose: Gets an ID from the user, and unsets the deleted flag.
  ==================================================
=============================
*/
void ui_UndeleteEntry(void *Dummy)
{
struct Record *rec;
int choice;

if (gl_HighestID == 0)
{
printf ("No entries in the database!\n");
io_EnterToContinue();
return;
}

printf("Enter Record ID Number (1-%d, x to exit) >", gl_HighestID);
if ((choice = io_GetInt(gl_HighestID)) == RC_BAD)
return;
if ((rec = li_GetDataPtrByID(gl_AppData.MainList, choice)) == NULL)
{
printf("No such entry: %d\n", choice);
io_EnterToContinue();
return;
}

if (rec->Status & ST_DELETED)
{
rec->Status = rec->Status ^ ST_DELETED;
printf ("Record undeleted\n");
gl_AppData.DataChanged = TRUE;
if (gl_AppCfg.AutoSave) (void)io_WriteAllRecordsToFile(gl_AppData.MainList);
}
else
printf ("Record was not marked for deletion\n");

io_EnterToContinue();

}

/*
  ==================================================
=============================
  Function:  ui_SearchByID
    Args:  None
    Returns:  Nothing
    Purpose: Gets an ID from the user, then display that Record in detail
  ==================================================
=============================
*/
void ui_SearchByID(void)
{
struct Record *rec;
int choice;

if (gl_HighestID == 0)
{
printf ("No entries in the database!\n");
io_EnterToContinue();
return;
}
printf("Enter Record ID Number (1-%d, x to exit) >", gl_HighestID);
if ((choice = io_GetInt(gl_HighestID)) == RC_BAD)
return;
if ((rec = li_GetDataPtrByID(gl_AppData.MainList, choice)) == NULL)
printf("No such entry: %d\n", choice);
else rec_PrintLong(rec);
io_EnterToContinue();
}

/*
  ==================================================
=============================
  Function:  ui_SearchAll
    Args:  Field type
    Returns:  Nothing
    Purpose: Gets search criteria from user, the traverses the list, short
     printing each record that matches the criteria.
  ==================================================
=============================
*/
void ui_SearchAll(void *WhichField)
{
char buffer[MAXL_FIELD + 1];
int i, len;

if (gl_HighestID == 0)
{
printf ("No entries in the database!\n");
io_EnterToContinue();
return;
}

if ((enum RECORD_FIELDS)WhichField == RECF_ID) 
{
ui_SearchByID();
return;
}

printf("Enter Criteria >");

if ((len = io_GetLine(buffer, MAXL_FIELD + 1, stdin)) != 0)
{
gl_AppData.SearchField = (enum RECORD_FIELDS)WhichField;
for (i = 0; i < len; i++) /* convert to lower case for search */
if (isupper(buffer[i])) buffer[i] = tolower(buffer[i]);
strncpy(gl_AppData.SearchText, buffer, MAXL_FIELD + 1);
gl_AppData.LinesDisplayedSoFar = 0;
(void)li_Traverse(gl_AppData.MainList, rec_SearchAndPrint);
}

io_EnterToContinue();
}

/*
  ==================================================
=============================
  Function:  ui_DisplayAll



  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
    Args:  None
    Returns:  Nothing
    Purpose: Traverses the list and does a short print of each record
  ==================================================
=============================
*/
void ui_DisplayAll(void *Dummy)
{
if (gl_HighestID == 0)
{
printf ("No entries in the database!\n");
io_EnterToContinue();
return;
}

gl_AppData.LinesDisplayedSoFar = 0;
gl_AppData.SearchField = RECF_DUMMY;
(void)li_Traverse(gl_AppData.MainList, rec_SearchAndPrint);
io_EnterToContinue();
}

/*
  ==================================================
=============================
  Function:  ui_Save
    Args:  None (NULL Pointer)
    Returns:  Nothing
    Purpose: Gets confirmation from the user, then saves the current list to disk
  ==================================================
=============================
*/
void ui_Save(void *Dummy)
{
if (io_GetYesNo("Confirm Save (including purge of deleted records) (y/n) >") == TRUE)
{
(void)io_WriteAllRecordsToFile(gl_AppData.MainList);
}
}

/*
  ==================================================
=============================
  Function:  ui_PurgeDeleted
    Args:  None (NULL Pointer)
    Returns:  Nothing
    Purpose: Gets confirmation from the user, then traverses the list,
     removing (free'ing) any records that are marked as deleted
  ==================================================
=============================
*/
void ui_PurgeDeleted(void *Dummy)
{
unsigned char status = ST_DELETED;

if (gl_HighestID == 0)
{
printf ("No entries in the database!\n");
io_EnterToContinue();
return;
}

if (io_GetYesNo("Confirm Purge (y/n) >") == TRUE)
gl_AppData.MainList = li_DeleteNodeAndData (gl_AppData.MainList, &status, rec_CompareStatus);
}

/*
  ==================================================
=============================
    Function:  ui_ShowInfo
    Args:  None (NULL Pointer)
    Returns:  Nothing
    Purpose: Displays stats about the program and the PhoneBook
  ==================================================
=============================
 */
void ui_ShowInfo(void *Dummy)
{
printf ("--->\n---> **PhoneBook** - Version: %s\n", PRG_VERSION);
printf ("---> Written By *Hammer* for the C Programming Contest\n");
printf ("---> held by http://www.cprogramming.com/cboard/ in May 2002\n");
printf ("---> You can contact the author via email: claw_hammer@hotmail.com\n");
printf ("--->\n---> The PhoneBook datafile is %s\n", STR_FILENAME);
printf ("---> The PhoneBook configuration file is %s\n", STR_CFG_FILENAME);
printf ("--->\n---> There are currently %d entries loaded.\n", li_Count(gl_AppData.MainList));
printf ("--->\n---> This program accepts command line information\n");
printf ("---> For example (assuming the program name is phone.exe):\n");
printf ("--->   >phone.exe hammer tommy\n");
printf ("---> will result in the database being searched for the\n");
printf ("---> names hammer and tommy and the results being displayed.\n");
printf ("---> In this case, the menu is not loaded, and the\n");



  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
printf ("---> program terminates.  This is useful for quick lookups.\n");
printf ("--->\n");
io_EnterToContinue();
}

/*
  ==================================================
=============================
  Function:  ui_ToggleAutoSave
    Args:  None (NULL Pointer)
    Returns:  Nothing
    Purpose: Allows the user to turn auto-save off and on.
  ==================================================
=============================
*/
void ui_ToggleAutoSave(void *Dummy)
{
printf ("Auto-Save is currently %s\n", (gl_AppCfg.AutoSave)?"On":"Off");
if (io_GetYesNo("Toggle auto-save (y/n) >") == TRUE)
{
gl_AppCfg.AutoSave = ~gl_AppCfg.AutoSave;
printf ("Auto-Save is now %s\n", (gl_AppCfg.AutoSave)?"On":"Off");
io_EnterToContinue();
}
}

/*
  ==================================================
=============================
  Function:  ui_SetLinesPerDisplay
    Args:  None (NULL Pointer)
    Returns:  Nothing
    Purpose: Allows the user to set the number of lines displayed in lists
     before a io_EnterToContinue is called.
  ==================================================
=============================
*/
void ui_SetLinesPerDisplay(void *Dummy)
{
int Lines;

printf ("This option determines how many lines are output to the screen\nbefore a \"hit enter to continue\" message is displayed\n");
printf ("The current setting is %d\n", gl_AppCfg.LinesPerDisplay);
printf ("Enter a new number or x to exit >");

if ((Lines = io_GetInt(MAX_LINES_PER_PAGE)) == RC_BAD)
return;

gl_AppCfg.LinesPerDisplay = Lines;
printf ("The new setting is %d\n", gl_AppCfg.LinesPerDisplay);
io_EnterToContinue();
}

/*
  ==================================================
=============================
  Function:  ui_SetSortBy
    Args:  Field type
    Returns:  Nothing
    Purpose: Allows the user to set the sort order
  ==================================================
=============================
*/
void ui_SetSortBy(void *WhichField)
{
gl_AppCfg.SortField = (enum RECORD_FIELDS)WhichField;

printf ("Sorting the data...");
li_Sort (gl_AppData.MainList, rec_Compare); 
printf ("Done!\n");
io_EnterToContinue();
}



  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include "main.h"

/*
 ==================================================
=============================
  Author: Hammer, May 2002, For www.cprogramming.com/cboard/
  File: ioUtilities.c
  Contents: io_GetInt
io_EnterToContinue
io_GetYesNo
io_GetLine
io_WriteAllRecordsToFile
io_WriteRecordToFile
io_LoadAppConfig
io_SaveAppConfig
 ==================================================
=============================
*/

static FILE *fp;

/*
 ==================================================
=============================
  Function:  ioLoadPhoneBookFromFile
 Args:  Pointer to the node list 
 Returns:  Pointer to the node list.
  NULL
 Purpose: Loads the Record structs from the phone book file into the List
 ==================================================
=============================
*/
struct Node *io_LoadPhoneBookFromFile(struct Node *List)
{
struct Record rec, *recptr;
struct Node *tmpListPtr;

if ((fp = fopen(STR_FILENAME, "rb")) == NULL)
{ /* Failed to open database file */
printf("ERROR: Unable to open phone book file: %s\n", STR_FILENAME);
return(List);
}

if (List)
{ /* List not empty, kill it before we start reloading */
(void)li_Traverse(List, free);
List = li_Destroy(List);
}

while (fread(&rec, sizeof(struct Record), 1, fp) == 1)
{
if ((recptr = malloc(sizeof(struct Record))) == NULL)
{ /* Memory failure, don't do anymore */
perror("malloc");
break;
}

*recptr = rec;

if ((tmpListPtr = li_Insert(List, recptr, rec_Compare)) == NULL)
{
printf("Error performing insert on list. Item not addded.\n");
free(recptr); /* throw record away */
}
else
{
List = tmpListPtr;
recptr->ID = gl_HighestID;
recptr->Status = (unsigned char)0;
}
}

(void)fclose(fp);
gl_AppData.DataChanged = FALSE;
return(List);
}

/*
 ==================================================
=============================
 Function:  io_GetInt
 Args: maximum number for user to choose
 Returns:  Number chosen, or -1 if x or X entered (for menu use)
 Notes: Assumes that 0 will never be a valid option, and will ask
  the user to re-enter.
 Purpose: Get an int from stdin (keyboard).
 ==================================================
=============================
 */
int io_GetInt(int Max)
{
int Input, len;
char buffer[BUFSIZ];

for (;;)
{
if ((len = io_GetLine(buffer, BUFSIZ, stdin)) != 0)
{
if (len == 1 && (buffer[0] == 'x' || buffer[0] == 'X'))
{ /* Allow for xX to be entered, and return -1 */
Input = RC_BAD;
break;
}

if ((Input = atoi(buffer)) != 0)
{
if (Input >= 1 && Input <= Max)
{
break;
}
}
}

printf("Invalid. Try again (1-%d, x to exit)>", Max);
}

return(Input);
}

/*
 ==================================================
=============================
 Function:  io_EnterToContinue
 Args:  None
 Returns:  None
 Purpose: Simulates the good old DOS PAUSE
 ==================================================



2025-11-18 06:48:55
广告
不感兴趣
开通SVIP免广告
  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
=============================
 */
void io_EnterToContinue(void)
{
printf("---> Enter To Continue <---");
FLUSH_INPUT;
}

/*
 ==================================================
=============================
 Function:  io_GetYesNo
 Args:  String containing the prompt to be displayed
 Returns:  TRUE if yY entered, FALSE if nN entered
 Purpose: Get a Y or N from stdin (keyboard)
 ==================================================
=============================
 */
bool_t io_GetYesNo(char *prompt)
{
int c;
bool_t rc;

for (;;)
{
printf("%s", prompt);
c = getchar();
switch ©
{
case 'y':
case 'Y':
rc = TRUE;
break;
case 'n':
case 'N':
rc = FALSE;
break;
default:
if (c != '\n') FLUSH_INPUT;
continue;
}
break;
}

if (c != '\n') FLUSH_INPUT;
return(rc);
}

/*
 ==================================================
=============================
 Function:  io_GetLine
 Args:  buffer to place the text
  length of the buffer
  file pointer to read from.
 Returns:  Chars read and placed into buffer
 Purpose: Same as fgets() but does not keep the newline character
 ==================================================
=============================
 */
int io_GetLine(char *buffer, int maxlen, FILE *fp)
{
int len = 0, c;
char *ptr = buffer;
char *endptr = buffer + maxlen - 1;

if (fp != NULL)
{
while ((c = fgetc(fp)) != EOF)
{
if (c == '\n') break;
*ptr = c;
ptr++;
len++;
if (ptr == endptr) break;
}
}

*ptr = '\0';
return(len);
}

/*
 ==================================================
=============================
 Function:  io_WriteAllRecordsToFile
 Args:  Pointer to list 
 Returns:  Number of items written.
 Purpose: Save all Record structs in the List to a disk file
 ==================================================
=============================
 */int io_WriteAllRecordsToFile(struct Node *List)
{
unsigned char status = ST_DELETED;

if ((fp = fopen(STR_FILENAME, "wb")) == NULL)
{ /* Failed to open database file */
printf("ERROR: Unable to open phone book file: %s\n", STR_FILENAME);
return(0);
}

/* First delete dead records from the list, then write them to disk */
gl_AppData.MainList = li_DeleteNodeAndData(gl_AppData.MainList, &status, rec_CompareStatus);
(void)li_Traverse(List, io_WriteRecordToFile);

(void)fclose(fp);

gl_AppData.DataChanged = FALSE;
return(gl_HighestID);
}

/*
 ==================================================
=============================
 Function:  io_WriteRecordToFile
 Args:  Pointer to record structure to be written.
 Returns:  Nothing
 Purpose: Sub-function to write a single Record struct to disk
 ==================================================
=============================
 */
void io_WriteRecordToFile(void *ptr)
{
struct Record *rec = ptr;

if (rec->Status & ST_DELETED) return; /* Don't save deleted records */

if (fp == NULL)
{
fprintf(stderr, "ERROR: Attempting to write to unopened file\n");
return;
}

if (fwrite(rec, sizeof(struct Record), 1, fp) != 1) perror("WriteRecordToFile");
}

/*
 ==================================================
=============================
 Function:  io_LoadAppConfig
 Args:  None
 Returns:  Nothing
 Purpose: Loads the appconfig structure from disk
 ==================================================
=============================
 */
void io_LoadAppConfig(void)
{
FILE *myfp;
struct appconfig tmpcfg;

if ((myfp = fopen(STR_CFG_FILENAME, "rb")) == NULL) return;
if (fread(&tmpcfg, sizeof(struct appconfig), 1, myfp) == 1) gl_AppCfg = tmpcfg;

(void)fclose(myfp);
}

/*
 ==================================================
=============================
 Function:  io_SaveAppConfig
 Args:  None
 Returns:  Nothing
 Purpose: Saves the appconfig structure to disk
 ==================================================
=============================
 */
void io_SaveAppConfig(void)
{
FILE *myfp;

if ((myfp = fopen(STR_CFG_FILENAME, "wb")) == NULL) return;

if (fwrite(&gl_AppCfg, sizeof(struct appconfig), 1, myfp) != 1)
perror (STR_CFG_FILENAME);

(void)fclose(myfp);
}


  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include "main.h"

/*
 ==================================================
=============================
  Author: Hammer, May 2002, For www.cprogramming.com/cboard/
  File: ListUtilities.c
  Contents: li_Create
  nd_Create
  nd_Destroy
  li_Traverse
  li_Insert
  li_Destroy
  li_GetDataPtrByID
  li_DeleteNodeAndData
  li_Count
 ==================================================
=============================
*/

/*
 ==================================================
=============================
 Function:  li_Create
 Args:  None
 Returns:  NULL pointer.
 Purpose: Dummy function to start off a list.
 ==================================================
=============================
 */
struct Node *li_Create(void)
{
return (NULL);
}
 
/*
 ==================================================
=============================
 Function:  nd_Create
 Args:  A void ptr to the data to be referenced (A record).
 Returns:  Pointer to new node, ready for insertion into the tree.
  NULL if malloc fails
 Purpose: Creates a single node, containing a pointer to some data (Record)
 ==================================================
=============================
 */
struct Node *nd_Create(void *ptr, struct Node *NextNode)
{
struct Node *newptr;

if ((newptr = malloc(sizeof(struct Node))) == NULL)
{
perror("nd_create, malloc");
return (NULL);
}

newptr->DataPtr = ptr;
newptr->Next = NextNode;
return(newptr);
}

/*
 ==================================================
=============================
 Function:  nd_Destroy
 Args:  A pointer to a node to be free()'d
 Returns:  Nothing
 Purpose: The data the node points to is not freed by the function, 
  only the node itself is.
 ==================================================
=============================
 */
void nd_Destroy(struct Node *ptr)
{
free(ptr);
}

/*
 ==================================================
=============================
 Function:  li_Traverse
 Args:  A pointer to the first node in the list
  A pointer to a function used to process each node.
 Returns:  Number of Nodes processed
 Purpose: Traverse the list, sending each nodes data to a function
 ==================================================
=============================
 */
int li_Traverse(struct Node *List, FPTR_Action fptr_Action)
{
struct Node *Current = List;
int Count = 0;

while (Current)
{
fptr_Action(Current->DataPtr);
Count++;
Current = Current->Next;
}
return (Count);
}
/*
 ==================================================
=============================
 Function:  li_Insert
 Args:  A pointer to the first node in the list
  A pointer to the data to be referenced by the node
  A pointer to a function to be used for comparison.
 Returns:  Pointer to the first node in the list
  NULL is nd_Create fails.
 Notes: The caller should use caution to ensure the List pointer
  is not lost if this function returns NULL.
 Purpose: Inserts a new node into the list in the correct sorted order.



  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 ==================================================
=============================
 */
struct Node *li_Insert(struct Node *List, void *NewData, FPTR_Compare fptr_Compare)
{
struct Node *newptr;
struct Node *Current = List;
struct Node *Previous = NULL;

while (Current)
{
if (fptr_Compare(Current->DataPtr, NewData) > 0)
break; /* Found the entry point */
Previous = Current; 
Current = Current->Next;
}

if ((newptr = nd_Create(NewData, Current)) == NULL)
{ /* malloc failure in nd_Create */
return (NULL);
}

if (Previous == NULL)
List = newptr;
else
Previous->Next = newptr;

gl_HighestID++;
return (List);
}

/*
 ==================================================
=============================
 Function:  li_Destroy
 Args:  A pointer to the first node in the list
 Returns:  Nothing
 Purpose: This runs through the list, destroying nodes. It does
  not free the data that each node points to.
 ==================================================
=============================
 */
struct Node *li_Destroy(struct Node *List)
{
struct Node *Current = List;
struct Node *tmp;

while (Current)
{
tmp = Current->Next;
nd_Destroy(Current);
Current = tmp;
}
gl_HighestID = 0;

return (NULL);
}

/*
 ==================================================
=============================
 Function:  li_GetDataPtrByID
 Args:  A pointer to the first node in the list
  An int for the ID field.
 Returns:  Pointer to a Record struct, allowing direct access by the caller
 Purpose: Gets the address of a Record structure, as *owned* by the list.
 ==================================================
=============================
*/
struct Record *li_GetDataPtrByID(struct Node *List, int ID)
{
struct Node *Current = List;
struct Record *rec;

while (Current)
{
rec = Current->DataPtr;
if (rec->ID == ID)
break;
Current = Current->Next;
}
return ((Current)?Current->DataPtr:NULL);
}

/*
 ==================================================
=============================
 Function:  li_DeleteNodeAndData
 Args:  A pointer to the first node in the list
  A pointer to the data to be referenced by the node
  A pointer to a function to be used for comparison.
 Returns:  Pointer to the first node in the list
  NULL is nd_Create fails.
 Notes: The caller should use caution to ensure the List pointer
  is not lost if this function returns NULL.
 Purpose: As the function name says!
 ==================================================
=============================
 */
struct Node *li_DeleteNodeAndData(struct Node *List, void *CompareData, FPTR_CompareDelete fptr_Compare)
{
struct Node *Current = List;
struct Node *Previous = NULL;
struct Node *tmp;

while (Current)
{
if (fptr_Compare(Current->DataPtr, CompareData) > 0)
{ /* Found a node to remove */
if (Current == List) List = Current->Next;
tmp = Current->Next;
if (Previous)
{
Previous->Next = tmp;
}
free (Current->DataPtr);
free (Current);
Current = tmp;
}
else
{ /* No match, move on */
Previous = Current; 
Current = Current->Next;
}
}

return (List);
}

/*
 ==================================================
=============================
 Function:  li_Count
 Args:  A pointer to the first node in the list
 Returns:  Number of Nodes in list
 Purpose: Counts the nodes.
 ==================================================
=============================
 */
int li_Count(struct Node *List)
{
struct Node *Current = List;
int Count = 0;

while (Current)
{
Count++;
Current = Current->Next;
}
return (Count);
}

/*
 ==================================================
=============================
 Function:  li_Sort
 Args:  A pointer to the first node in the list
  Function pointer used for comparisons
 Returns:  None
 Purpose: Sorts the nodes, using the given function.
 ==================================================
=============================
 */
void li_Sort(struct Node *List, FPTR_Compare fptr_Compare)
{
struct Node *Current, *Next;
void *Temp;
bool_t StillDoingSwaps = TRUE;

while (StillDoingSwaps == TRUE)
{
StillDoingSwaps = FALSE;
Current = List;
while (Current)
{
if ((Next = Current->Next) != NULL)
{
if (fptr_Compare (Current->DataPtr, Next->DataPtr) > 0)
{
Temp = Current->DataPtr;
Current->DataPtr = Next->DataPtr;
Next->DataPtr = Temp;
StillDoingSwaps = TRUE;
}
}
Current = Next;
}
}
}


  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
}

/*
 ==================================================
=============================
 Function:  rec_PrintLong
 Args:  A pointer to a Record struct to be printed
 Returns:  Nothing
 Purpose: Prints all fields from a single Record struct
 ==================================================
=============================
 */
void rec_PrintLong(void *ptr)
{
struct Record *rec = ptr;

printf ("Record ID:\t%d %s\n", rec->ID, (rec->Status & ST_DELETED)?"(Deleted)":"");
printf ("Name:\t\t%s\n", rec->Name);
printf ("1st Phone:\t%s\n", rec->PhoneNum1);
printf ("2nd Phone:\t%s\n", rec->PhoneNum2);
printf ("3rd Phone:\t%s\n", rec->PhoneNum3);
printf ("Address:\t%s\n", rec->AddrLine1);
if (rec->AddrLine2[0] != '\0') printf (" \t%s\n", rec->AddrLine2);
if (rec->AddrLine3[0] != '\0') printf (" \t%s\n", rec->AddrLine3);
if (rec->AddrLine4[0] != '\0') printf (" \t%s\n", rec->AddrLine4);
if (rec->AddrLine5[0] != '\0') printf (" \t%s\n", rec->AddrLine5);
printf ("Email Addr:\t%s\n", rec->EmailAddr);
printf ("Misc Data:\t%s\n", rec->Misc);
}

/*
 ==================================================
=============================
 Function:  rec_SearchAndPrint
 Args:  A pointer to a Record struct to be printed (if criteria meet)
 Returns:  Nothing
 Purpose: Called during the list traversal process, this function will
  search a specified field for the search string stored in the
  global struct gl_AppData.SearchText
 ==================================================
=============================
 */
void rec_SearchAndPrint(void *ptr)
{
struct Record *rec = ptr;
char *sptr, *tmp;
int len, i;
char rectext[MAXL_FIELD+1];

if (gl_AppData.SearchField == RECF_DUMMY)
sptr = NULL;
else sptr = rec_GetFieldPointer(rec, gl_AppData.SearchField);

if (sptr)
{
strncpy(rectext, sptr, MAXL_FIELD+1);

len = strlen(rectext);
/* Convert data to lower case to allow for case insensative search */
for (i = 0, tmp = rectext; i < len; i++, tmp++)
{if (isupper(*tmp)) *tmp = tolower(*tmp);}
if (!strstr(rectext, gl_AppData.SearchText))
return;
}

rec_PrintShort(ptr);

gl_AppData.LinesDisplayedSoFar++;
if (gl_AppData.LinesDisplayedSoFar == gl_AppCfg.LinesPerDisplay)
{
io_EnterToContinue();
gl_AppData.LinesDisplayedSoFar = 0;
}
}

/*
 ==================================================
=============================
 Function:  rec_GetFieldPointer
 Args:  A pointer to a Record struct, and a field type indicator
 Returns:  A char pointer to the start of the field specified by the type indicator
 Purpose: Quick way to obtain string from the Record struct.
 ==================================================
=============================
 */
char *rec_GetFieldPointer(const struct Record *rec, enum RECORD_FIELDS WhichField)
{
char *sptr;
switch (WhichField)
{
case RECF_NAME: sptr = (char *)rec->Name; break;
case RECF_PHONENUM1: sptr = (char *)rec->PhoneNum1; break;
case RECF_PHONENUM2: sptr = (char *)rec->PhoneNum2; break;
case RECF_PHONENUM3: sptr = (char *)rec->PhoneNum3; break;
case RECF_ADDRLINE1: sptr = (char *)rec->AddrLine1; break;
case RECF_ADDRLINE2: sptr = (char *)rec->AddrLine2; break;
case RECF_ADDRLINE3: sptr = (char *)rec->AddrLine3; break;
case RECF_ADDRLINE4: sptr = (char *)rec->AddrLine4; break;
case RECF_ADDRLINE5: sptr = (char *)rec->AddrLine5; break;
case RECF_EMAILADDR: sptr = (char *)rec->EmailAddr; break;
case RECF_MISC: sptr = (char *)rec->Misc; break;
default: sptr = (char *)rec->Name; break;
}
return (sptr);
}


  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
}

/*
 ==================================================
=============================
 Function:  rec_PrintLong
 Args:  A pointer to a Record struct to be printed
 Returns:  Nothing
 Purpose: Prints all fields from a single Record struct
 ==================================================
=============================
 */
void rec_PrintLong(void *ptr)
{
struct Record *rec = ptr;

printf ("Record ID:\t%d %s\n", rec->ID, (rec->Status & ST_DELETED)?"(Deleted)":"");
printf ("Name:\t\t%s\n", rec->Name);
printf ("1st Phone:\t%s\n", rec->PhoneNum1);
printf ("2nd Phone:\t%s\n", rec->PhoneNum2);
printf ("3rd Phone:\t%s\n", rec->PhoneNum3);
printf ("Address:\t%s\n", rec->AddrLine1);
if (rec->AddrLine2[0] != '\0') printf (" \t%s\n", rec->AddrLine2);
if (rec->AddrLine3[0] != '\0') printf (" \t%s\n", rec->AddrLine3);
if (rec->AddrLine4[0] != '\0') printf (" \t%s\n", rec->AddrLine4);
if (rec->AddrLine5[0] != '\0') printf (" \t%s\n", rec->AddrLine5);
printf ("Email Addr:\t%s\n", rec->EmailAddr);
printf ("Misc Data:\t%s\n", rec->Misc);
}

/*
 ==================================================
=============================
 Function:  rec_SearchAndPrint
 Args:  A pointer to a Record struct to be printed (if criteria meet)
 Returns:  Nothing
 Purpose: Called during the list traversal process, this function will
  search a specified field for the search string stored in the
  global struct gl_AppData.SearchText
 ==================================================
=============================
 */
void rec_SearchAndPrint(void *ptr)
{
struct Record *rec = ptr;
char *sptr, *tmp;
int len, i;
char rectext[MAXL_FIELD+1];

if (gl_AppData.SearchField == RECF_DUMMY)
sptr = NULL;
else sptr = rec_GetFieldPointer(rec, gl_AppData.SearchField);

if (sptr)
{
strncpy(rectext, sptr, MAXL_FIELD+1);

len = strlen(rectext);
/* Convert data to lower case to allow for case insensative search */
for (i = 0, tmp = rectext; i < len; i++, tmp++)
{if (isupper(*tmp)) *tmp = tolower(*tmp);}
if (!strstr(rectext, gl_AppData.SearchText))
return;
}

rec_PrintShort(ptr);

gl_AppData.LinesDisplayedSoFar++;
if (gl_AppData.LinesDisplayedSoFar == gl_AppCfg.LinesPerDisplay)
{
io_EnterToContinue();
gl_AppData.LinesDisplayedSoFar = 0;
}
}

/*
 ==================================================
=============================
 Function:  rec_GetFieldPointer
 Args:  A pointer to a Record struct, and a field type indicator
 Returns:  A char pointer to the start of the field specified by the type indicator
 Purpose: Quick way to obtain string from the Record struct.
 ==================================================
=============================
 */
char *rec_GetFieldPointer(const struct Record *rec, enum RECORD_FIELDS WhichField)
{
char *sptr;
switch (WhichField)
{
case RECF_NAME: sptr = (char *)rec->Name; break;
case RECF_PHONENUM1: sptr = (char *)rec->PhoneNum1; break;
case RECF_PHONENUM2: sptr = (char *)rec->PhoneNum2; break;
case RECF_PHONENUM3: sptr = (char *)rec->PhoneNum3; break;
case RECF_ADDRLINE1: sptr = (char *)rec->AddrLine1; break;
case RECF_ADDRLINE2: sptr = (char *)rec->AddrLine2; break;
case RECF_ADDRLINE3: sptr = (char *)rec->AddrLine3; break;
case RECF_ADDRLINE4: sptr = (char *)rec->AddrLine4; break;
case RECF_ADDRLINE5: sptr = (char *)rec->AddrLine5; break;
case RECF_EMAILADDR: sptr = (char *)rec->EmailAddr; break;
case RECF_MISC: sptr = (char *)rec->Misc; break;
default: sptr = (char *)rec->Name; break;
}
return (sptr);
}


  • 风户京介
  • 初试啼声
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
d


2025-11-18 06:42:55
广告
不感兴趣
开通SVIP免广告
  • 泥巴的泥
  • 关键时刻
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
/* Turbo C - (C) Copyright 1987,1988 by Borland International */

#include <dos.h>
#include <stdio.h>
#include <string.h>
#include <mem.h>
#include <conio.h>
#include "mcalc.h"

static unsigned char colortable[256];

void setcolor(int color)
/* Sets the current color using the color table */
{
 textattr(colortable[color]);
} /* setcolor */

void writef(int col, int row, int color, int width, va_list arg_list, ...)
/* Prints a string in video memory at a selected location in a color */
{
 va_list arg_ptr;
 char *format;
 char output[81];
 int len;

 va_start(arg_ptr, arg_list);
 format = arg_list;
 vsprintf(output, format, arg_ptr);
 output[width] = 0;
 if ((len = strlen(output)) < width)
 setmem(&output[len], width - len, ' ');
 setcolor(color);
 gotoxy(col, row);
 cprintf(output);
} /* writef */

void scroll(int direction, int lines, int x1, int y1, int x2, int y2,
 int attrib)
/* Scrolls an area of the screen */
{
 if (lines == 0)
 window(x1, y1, x2, y2);
 else switch(direction)
 {
 case UP :
 movetext(x1, y1 + lines, x2, y2, x1, y1);
 window(x1, y2 - lines + 1, x2, y2);
 break;
 case DOWN :
 movetext(x1, y1, x2, y2 - lines, x1, y1 + lines);
 window(x1, y1, x2, y1 + lines - 1);
 break;
 case LEFT :
 movetext(x1 + lines, y1, x2, y2, x1, y1);
 window(x2 - lines + 1, y1, x2, y2);
 break;
 case RIGHT :
 movetext(x1, y1, x2 - lines, y2, x1 + lines, y1);
 window(x1, y1, x1 + lines - 1, y2);
 break;
 } /* switch */
 setcolor(attrib);
 clrscr();
 window(1, 1, 80, 25);
} /* scroll */

void setcursor(unsigned int shape)
/* Sets the shape of the cursor */
{
 union REGS reg;

 reg.h.ah = 1;
 reg.x.cx = shape;
 int86(0X10, ®, ®);
} /* setcursor */

unsigned int getcursor(void)
/* Returns the shape of the current cursor */
{
 union REGS reg;

 reg.h.ah = 3;
 reg.h.bh = 0;
 int86(0X10, ®, ®);
 return(reg.x.cx);
} /* getcursor */

void changecursor(insmode)
/* Changes the cursor shape based on the current insert mode */
{
 if (insmode)
 setcursor(tallcursor);
 else
 setcursor(shortcursor);
} /* changecursor */

void printcol(void)
/* Prints the column headings */
{
 int col;
 char colstr[MAXCOLWIDTH + 1];

 scroll(UP, 0, 1, 2, 80, 2, HEADERCOLOR);
 for (col = leftcol; col <= rightcol; col++)
 {
 centercolstring(col, colstr);
 writef(colstart[col - leftcol] + 1, 2, HEADERCOLOR, colwidth[col], colstr);
 }
} /* printcol */

void clearlastcol()
/* Clears any data left in the last column */
{
 int col;

 if ((col = colstart[rightcol - leftcol] + colwidth[rightcol]) < 80)
 scroll(UP, 0, col + 1, 3, 80, SCREENROWS + 2, WHITE);
} /* clearlastcol */

void printrow(void)
/* Prints the row headings */
{
 int row;

 for (row = 0; row < SCREENROWS; row++)
 writef(1, row + 3, HEADERCOLOR, LEFTMARGIN, "%-d", row + toprow + 1);
} /* printrow */

void displaycell(int col, int row, int highlighting, int updating)
/* Displays the contents of a cell */
{
 int color;
 char *s;

 if ((updating) &&
 ((cell[col][row] == NULL) || (cell[col][row]->attrib != FORMULA)))



登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 1 2 下一页 尾页
  • 20回复贴,共2页
  • ,跳到 页  
<<返回孙燕姿吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示