powershell真香

  • 写毕设开题报告,从PDF复制后会有多余空格,一个一个手动删除略显麻烦。

delete.cpp

#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;
int main()
{
    //freopen("UAS.txt","r",stdin);
    //freopen("UASOK.txt","w",stdout);
    char c;
    while((c=fgetc(stdin)) != EOF)
    {
        if(c != '
') printf("%c",c);
        else printf(" ");
    }
    return 0;
}

中途出了一些问题

  • 用getline(cin,s);读进来的s,s.size()莫名很大,最后处理完是乱码。//注:s为string类
  • 以及从文件读第一个字符就跳出了while循环,注释freopen后直接从stdin读入没问题,不知道问题出在哪儿。
  • 不知道在脚本中如何读取clipboard中的文本,这么偏的问题baidu是不可能找到的,这辈子都不可能的。最后谷歌出来powershell有提供Get-Clipboard。(Linux 下bash 有该功能的工具,如xclip等,我没试)

Get-Clipboard | ./a.exe | clip
原文地址:https://www.cnblogs.com/yhjd/p/10417776.html