c++ - 为什么只打印这些字符串的最后一个字母?

标签 c++ arrays string arduino

我很好奇 Arduino Leonardo 的键盘和鼠标库是否可以用作 Windows 用户密码暴力黑客。使用我有限的爱好编码和 arduino 技能,我开始为此编写一个程序。

问题一开始似乎是串行输出在本应输出通用密码时却输出了随机字母/数字。我花了一分钟才意识到这些是常用密码。嗯,他们每个人的最后一个字母。

代码:

// tests most common paswords, if one of these works your idiot alert should be ringing
char myStrings[26]={ 'password', '123456', '12345678',
'1234', 'qwerty','12345','password', 'dragon', 'pussy',
'baseball', 'football','monkey', 'letmein', '696969',
'abc123', 'mustang','michael', 'shadow', 'master',
'jennifer', 'harley','1234567', 'jordan',
'2000', '111111',
'COMMON PASSWORDS EXHAUSTED: ATTEMPTING BRUTE FORCE'};


//the letters... yep
char myLetters[26]={'a', 'b', 'c',
'd', 'e','f','g', 'h', 'i',
'j', 'k','l', 'm', 'n',
'o', 'p','q', 'r', 's',
't', 'u','v', 'w',
'x', 'y','z'};


//establishes serial connection
void setup(){
Serial.begin(9600);
}


void loop(){
for (int i = 0; i < 27; i++){
   Serial.println(myStrings[i]);
   }

   Serial.println("Common Finish"); // the common passwords have been attempted

   for (int o = 0; o < 26; o++){
   Serial.println(myLetters[o]);
   delay(500);
   }
   Serial.println("Letter Finish"); // the letters have been finished

   Serial.println("rinse wash repeat."); //the loop n' stuff

}

arduino 串口监视器图片:

Image of arduino serial monitor

对于我如何滥用数组或字符串的任何见解,我将不胜感激。谢谢。

最佳答案

'...' 用于单个字符。字符串使用 "...".

随后你的变量声明是错误的,因为它是一个字符数组。

但是you're doing it wrong in the first place .

关于c++ - 为什么只打印这些字符串的最后一个字母?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22134681/

相关文章:

python - numpy 有条件地用数组替换标量/ bool 值

javascript - 在网页中设计日历时如何根据下一个数组输入更改存储在数组中的事件对象的属性

regex - 如何在字符串中的单个单词周围添加引号,而不是在已经有引号的子字符串周围添加引号?

string - Typescript 类型 'string' 不可分配给类型 'never' 。错误

c++ - SFML/C++ Sprite 由于超出范围而显示为白框,不知道在哪里

c++ - 保存数据以便从体素编辑器中重新使用的最佳方式

c++ - 如何更改 QDoubleSpinBox 的大小?

c++ - 换行和回车

c - 二进制 == 在 'int' 和 'struct member' 之间,当两个值都是 int 时

java - 如何获取字符串数组中的数字并将它们放入 int 数组中