去除多條訊息中的使用者名稱(微信)
阿新 • • 發佈:2020-11-03
1 /** 2 去除多條訊息中的使用者名稱 3 比如: 微信多條訊息 4 **/ 5 #include <cstdio> 6 #include <cstdlib> 7 #include <cstring> 8 #include <assert.h> 9 #define _AFXDLL 10 //#include <afx.h> 11 #include <windows.h> 12 #include <iostream> 13 using namespace std; 14 const int max_len=1e6;15 16 char str_1[max_len],str_total[max_len]; 17 18 //void copy_to_clipboard(char str_1[max_len]) 19 //{ 20 /////https://zhidao.baidu.com/question/371455437.html 21 // 22 /////https://blog.csdn.net/daska110/article/details/80323447 23 // 24 // 25 // 26 // 27 //// char cD[] ="qq34r6"; 28 // if(OpenClipboard(NULL)) 29 // { 30 // HGLOBAL hmem=GlobalAlloc(GHND,7);31 // char *pmem=(char *)GlobalLock(hmem);///add (char *) 32 // 33 // EmptyClipboard(); 34 // memcpy(pmem,str_1,strlen(str_1)+1); 35 // SetClipboardData(CF_TEXT,hmem); 36 // CloseClipboard(); 37 // GlobalFree(hmem); 38 // } 39 //} 40 41 BOOL SetClipData(char *pstr) 42 { 43 ///https://www.cnblogs.com/emjx/p/11141572.html44 if(OpenClipboard(NULL)) 45 { 46 char *pBuf; 47 if(0==EmptyClipboard()) 48 { 49 CloseClipboard(); 50 return false; 51 } 52 HGLOBAL hClip=GlobalAlloc(GMEM_MOVEABLE,strlen(pstr)+1); 53 if(NULL==hClip) 54 { 55 CloseClipboard(); 56 return false; 57 } 58 pBuf=(char*)GlobalLock(hClip); 59 if(NULL==pBuf) 60 { 61 CloseClipboard(); 62 return false; 63 } 64 strcpy(pBuf,pstr); 65 GlobalUnlock(hClip); 66 67 if(NULL==SetClipboardData(CF_TEXT,hClip)) 68 { 69 CloseClipboard(); 70 return false; 71 } 72 73 CloseClipboard(); 74 } 75 return true; 76 } 77 78 int main() 79 { 80 ///Ctrl+Z + Enter 結束 81 while (gets(str_1)) 82 { 83 if (strcmp(str_1,"Traveller:")!=0) 84 { 85 ///人工修改格式(一開始沒留換行) 86 strcat(str_total,"\n"); 87 88 strcat(str_total,str_1); 89 } 90 } 91 printf("%s\n",str_total); 92 93 ///exe 94 ///放置訊息到剪貼簿 95 SetClipData(str_total); 96 // copy_to_clipboard(str_total); 97 return 0; 98 }
QQ 有時間:判斷去除
如 {name} + 2020/10/6 19:42:36
字串的規則