删除一行最前面的行号和空格(博客园)

 1 /**
 2 删除一行最前面的行号和空格
 3 比如博客园: "12 xxx"
 4 **/
 5 #include <cstdio>
 6 #include <cstdlib>
 7 #include <cstring>
 8 #include <iostream>
 9 using namespace std;
10 const int max_len=1e6;
11 
12 char str_1[max_len],str_total[max_len];
13 
14 BOOL SetClipData(char *pstr)
15 {
16 ///https://www.cnblogs.com/emjx/p/11141572.html
17     if(OpenClipboard(NULL))
18     {
19         char *pBuf;
20         if(0==EmptyClipboard())
21         {
22             CloseClipboard();
23             return false;
24         }
25         HGLOBAL hClip=GlobalAlloc(GMEM_MOVEABLE,strlen(pstr)+1);
26         if(NULL==hClip)
27         {
28             CloseClipboard();
29             return false;
30         }
31         pBuf=(char*)GlobalLock(hClip);
32         if(NULL==pBuf)
33         {
34             CloseClipboard();
35             return false;
36         }
37         strcpy(pBuf,pstr);
38         GlobalUnlock(hClip);
39 
40         if(NULL==SetClipboardData(CF_TEXT,hClip))
41         {
42             CloseClipboard();
43             return false;
44         }
45 
46         CloseClipboard();
47     }
48     return true;
49 }
50 
51 int main()
52 {
53     int i;
54     ///Ctrl+Z + Enter 结束
55     while (gets(str_1))
56     {
57         if (strcmp(str_1,"Traveller:")!=0)
58         {
59             ///人工修改格式(一开始没留换行)
60             strcat(str_total,"
");
61 
62             for (i=0;i<strlen(str_1);i++)
63                 if (str_1[i]==' ')
64                     break;
65 
66             strcat(str_total,str_1+i+1);
67         }
68     }
69     printf("%s
",str_total);
70 
71     ///放置消息到剪贴板
72     SetClipData(str_total);
73     return 0;
74 }
原文地址:https://www.cnblogs.com/cmyg/p/13921530.html