⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 这是一个由C语言开发的电话本程序,很有参考价值.
💻 C
字号:
#include "main.h"/*  =============================================================================== 	Author:		Hammer, May 2002, For www.cprogramming.com/cboard/ 	File:		main.c 	Contents:	Global variables 				main  ===============================================================================*//*  =============================================================================== 	The following are the only global variables  ===============================================================================*/int 	gl_HighestID;struct 	appdata gl_AppData;struct 	appconfig gl_AppCfg;/*  ===============================================================================    Function: 	main    Args: 		From command line.      			- This can be empty.  In this case an interactive menu is loaded.    			- or if present, it is taken to represent search criteria.      			In this case, the database is loaded, searched and the     			relevant records displayed, then the application terminates.    Returns: 	An int of course! (Always 0)     Don't void your main!    =============================================================================== */int main(int argc, char *argv[]){		struct Node *tmpListPtr;	int i;	/*	 * Load and setup app config	 */	memset (&gl_AppData, 0, sizeof(struct appdata));	memset (&gl_AppCfg, 0, sizeof(struct appconfig));		io_LoadAppConfig();		if (gl_AppCfg.LinesPerDisplay <= 0 || gl_AppCfg.LinesPerDisplay > MAX_LINES_PER_PAGE)		gl_AppCfg.LinesPerDisplay = DEF_LINES_PER_PAGE;		/*	 * Create and load the link list of Record structs	 */	gl_AppData.MainList = li_Create();			if ((tmpListPtr = io_LoadPhoneBookFromFile(gl_AppData.MainList)) == NULL)		printf("No data loaded from phone book.\n");	else gl_AppData.MainList = tmpListPtr;		/*	 * If we have command line args, use them as search criteria, then terminate	 */	if (argc > 1)	{		gl_AppData.SearchField = RECF_NAME;		for (i = 1; i < argc; i++)		{			strncpy(gl_AppData.SearchText, argv[i], MAXL_NAME+1);			(void)li_Traverse (gl_AppData.MainList, rec_SearchAndPrint);		}		(void)li_Traverse (gl_AppData.MainList, free);		(void)li_Destroy (gl_AppData.MainList);		return (0);	}		/*	 * Start interactive session, go into menu display until the user exits	 */	printf ("---> Auto-Save is %s <---\n", (gl_AppCfg.AutoSave)?"On":"Off");	ui_DisplayMenu(MainMenu);		/*	 * Check if we need to save changes, then destory the memory we alloc'd earlier	 */	if (gl_AppData.DataChanged)	{		ui_Save(NULL);	}		(void)li_Traverse (gl_AppData.MainList, free);		(void)li_Destroy (gl_AppData.MainList);		/*	 * Finally save the app config for next time	 */	io_SaveAppConfig();		return (0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -