会说话的电脑

· · 个人记录

#include <bits/stdc++.h>
using namespace std;

void speak(string the_world_say) {
    FILE *fp = fopen("%2%speak_c++.vbs", "w");
    string the_vbs_code =
        "CreateObject(\"Scripting.FileSystemObject\").DeleteFile(WScript.ScriptName)\nCreateObject(\"SAPI.SpVoice\").Speak\"" +
        the_world_say + "\"";
    fputs(the_vbs_code.c_str(), fp);
    fclose(fp);
    system("%2%speak_c++.vbs");
    return;
}
string str;

int main() {
    while (cin >> str) {
        speak(str);
    }
    return 0;
}