C++ Tab?????????????????
???????????? ???????[ 2014/3/27 10:07:49 ] ????????C++ Tab
??????????
?????????????д????????????????????ζ????У??????getline()?????????????α????????·?????????????????С?
?????????????鷳??д???tab????????????
?????????????????????????л?????????????????????????????ɡ?
????????????windows???????????
??????????????
????1.????????о???????????????в???????
#include<stdio.h>
#include<string>
#include<conio.h>
#include<map>
usingnamespacestd;
#include<windows.h>
#include<stdlib.h>
#include<wincon.h>
//tab????????????????????????
voidtab_find_char(std::map<int??char*>store_compare_??char*store_input??inti_store_input_count??int&tab_count);
//????????????????????????????????
char*get_attach(constchar*stacks_??constchar*needle_);
voidconsole_start();
voidconsole_end();
voidwrite(constchar*message??intlength);
voidwrite(constchar*message);
voidread(char*buffer??size_tsize);
#include<iostream>
#include"conio.h"
//?????????λ??
staticCOORDcurser_position;
voidmain()
{
console_start();
//??????????????????
staticstd::map<int??char*>store_compare;
store_compare[0]="thread_parameter_";
store_compare[1]="parameter_";
store_compare[2]="build";
store_compare[3]="compile";
intcount=0;
charch;
while(true)
{
inttab_count=0;
charstore_input[256];
inti_store_input_count=0;
//??????λ??
HANDLEhOut;
CONSOLE_SCREEN_BUFFER_INFObInfo;
hOut=GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hOut??&bInfo);
curser_position.X=bInfo.dwCursorPosition.X;
curser_position.Y=bInfo.dwCursorPosition.Y;
do
{
ch=(char)_getch();
if(ch!='
')
{
if(ch=='q')
{
break;
}
elseif(ch==9)
{
tab_find_char(store_compare??store_input??i_store_input_count??tab_count);
tab_count++;
}
//????????????????????????????
elseif((ch>=48&&ch<=57)||(ch>=65&&ch<=122))
{
char*temp_char=newchar[1];
temp_char[0]=ch;
write(temp_char??1);
store_input[i_store_input_count]=ch;
i_store_input_count++;
}
}
}
while(ch!='
');
write("
");
}
console_end();
}
voidtab_find_char(std::map<int??char*>store_compare_??char*store_input??inti_store_input_count??int&tab_count)
{
if(i_store_input_count<0||tab_count<0)
{
return;
}
intmap_size=store_compare_.size();
tab_count=tab_count%map_size;
i_store_input_count+=1;
store_input[i_store_input_count-1]='