📄 myaddressbook.cpp
字号:
// MyAddressBook.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "AddressBook.h"
#include <iostream>
#include <conio.h> //使用_getch函数
using namespace std;
CAddressBook myAddrBook;
char getLegalInput();
int main(int argc, char* argv[])
{
char userResponse;
bool exitApp = 0;
while (exitApp == 0)
{
myAddrBook.inputInformation();
cout << endl;
cout << "要继续输入数据吗?" << endl;
userResponse = getLegalInput();
if(userResponse == 'N' || userResponse == 'n')
{
exitApp = 1;
cout << "要查看文件内容吗?" << endl;
userResponse = getLegalInput();
if(userResponse == 'Y' || userResponse == 'y')
{
cout << "-----------文件内容-----------" << endl;
myAddrBook.displayFile("myAdrBook.txt");
}
cout << "按任意键程序将自动退出!" << endl;
}
else
{
exitApp = 0;
}
}
return 0;
}
char getLegalInput()
{
int ch;
_cputs( "请输入Y/y或N/n!" );
do
{
ch = _getch();
} while( ch != 'Y' && ch != 'y' && ch !='N' && ch != 'n');
_putch( ch );
_putch( '\r' );
_putch( '\n' );
return ch;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -