- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个将 int 映射到 char 的映射。 0-25 到字母 a-z 和 26-35 0-9。
for(int i = 0; i<26; i++)
{
letters.insert(Match::value_type(i,static_cast<char>(letter + x)));
x++;
}
for(int i = 26; i<36; i++)
{
letter = '0' + a;
letters.insert(Match::value_type(i,letter));
a++;
}
在这里i
输入pin[]
其中包含一个数字并查找值。
std::map<int, char >::const_iterator it1 = letters.find(pin[0]);
std::map<int, char >::const_iterator it2 = letters.find(pin[1]);
std::map<int, char >::const_iterator it3 = letters.find(pin[2]);
std::map<int, char >::const_iterator it4 = letters.find(pin[3]);
char fourth = it4->second;
char third = it3->second;
char second = it2->second;
char first = it1->second;
char combo[] = { first, second, third, fourth};
cout << combo << endl;
一切正常,但我的 cout<< combo
给我“abcd[[[[a[[[[[b[[[[c[[[[[d]]]]]pPP。”我不明白为什么...我想要的输出只是“abcd”我怎样才能清理它。
最佳答案
您需要null-terminate您的字符串才能在 C 风格模式下使用它。所以这将更改为:
char combo[] = { first, second, third, fourth, '\0'};
现在您正在输出内存中的垃圾,在 fourth
之后直到找到 null
字符。
关于c++ - char[] 乱七八糟的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15260571/
我关于套接字的代码分为三个类,现在我已经研究它(并学习套接字 Api)几个小时了,我已经把它归结为只剩下一个错误(我可以看)。从服务器收到的消息将不会打印,而是抛出此错误。 Exception in
当我打开个人热点连接时,我的布局被下推。我怎样才能删除顶部的这个热点栏或者得到这个栏的通知并根据它重新排列我的 View ?谢谢。 最佳答案 当状态栏的大小发生变化时,将调用您的应用程序委托(dele
我正在编写一个 Chrome 扩展,它在现有页面的顶部插入一个 DIV。我为我的 DIV 指定了不同的 ID 名称“juxiSidebar”。此外,我插入到页面中的所有 ID 和类都包含前缀“juxi
我正在为我的工作创建一个 Javascript 框架,支持最现代的浏览器(FF 4+、Chrome、Opera 11+、IE8+)。我在尝试扩展 prototype 时遇到了一些问题样式规则(假设 r
我是一名优秀的程序员,十分优秀!