用过Linux系统的人哪怕是初学者,估计也会对TAB补齐有好感
现在要在windows平台下模拟一个Linux的文件系统,TAB补齐这么赞的功能怎能缺失
便自己写了一个玩玩:
代码在下面:
// tab.cpp: 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <stdio.h>
#include <string>
#include <conio.h>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
vector <string> vc_of_str;
/*
ubuntu中的tab自动补全功能
在输入第一个操作数的时候是补全所有的指令
输入第二个操作数的时候是补全所有的当前目录下的东西
*/
int main() {
string s1, s2;
vc_of_str.push_back("cd");
vc_of_str.push_back("mkdir");
vc_of_str.push_back("ls");
vc_of_str.push_back("vi");
vc_of_str.push_back("sudo");
vc_of_str.push_back("rm");
vc_of_str.push_back("touch");
vc_of_str.push_back("man");
vc_of_str.push_back("cat");
vc_of_str.push_back("clear");
string s;
int tabcount = 0;
while (1) {
int ch = _getch();
if (ch == 8) { //退格