我正在尝试编写基本的JavaScript,它将段落的背景更改为黄色,然后在单击时将其更改为粉红色.
<p id="foo">Hello, people!</p>
Run Code Online (Sandbox Code Playgroud)
和脚本是
window.onload = function(){
var foo = document.getElementById("foo");
foo.onclick = function(){
if(foo.style.background!=="yellow")foo.style.background = "yellow";
if(foo.style.background === "yellow") foo.style.background = "pink";
};
};
Run Code Online (Sandbox Code Playgroud)
第一次点击时颜色变为黄色,但再次点击时颜色不会变为粉红色.我无法弄清楚这个问题.
我按照本教程在github上生成SSH密钥:在上面链接教程的第5步,在我输入后我ssh -T git@github.com应该看到这个:
The authenticity of host 'github.com (207.97.227.239)' can't be established.
# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
# Are you sure you want to continue connecting (yes/no)?
Run Code Online (Sandbox Code Playgroud)
但是,我看到了这个:
Agent admitted failure to sign using the key.
Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
然后,当我尝试使用文件将文件推送到存储库时git push -u origin master,我得到了这个:
Agent admitted failure to sign using the key.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)
我认为问题在于设置SSH密钥.我怎样才能解决这个问题?
我正在使用Linux.
这是我正在使用的代码片段:
int *a;
int p = 10;
*(a+0) = 10;
*(a+1) = 11;
printf("%d\n", a[0]);
printf("%d\n", a[1]);
Run Code Online (Sandbox Code Playgroud)
现在,我希望它能打印出来
10
11
Run Code Online (Sandbox Code Playgroud)
但是,会出现一个窗口,显示program.exe已停止工作.如果我注释掉第二行代码int p = 10;然后再次调试代码就行了.
为什么会这样?(我想要做的是创建一个动态大小的数组.)
以下是从单个链接列表尾部删除元素的代码的一部分:
int SLList::deleteFromTail()
{
int el = tail->info;
//if the list has only one element
if(head == tail) {
delete head;
head = tail = 0;
}
else {
//some code here...
}
return el
}
Run Code Online (Sandbox Code Playgroud)
这里head和tail是指向LL的第一和最后一个元素,分别.
在我们设置if之后的上面的块delete head中head = tail = 0.
但是在我们删除之后,我们head如何才能将它的价值设定为某种东西?(NULL在这种情况下)
#include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
int arr[] = {1,4,2,3,5,6};
int *p = arr;
delete p;
for(int i = 0 ; i < 6; i++)
cout << p[i];
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出是142356。当我说delete p为什么不删除 p 时?
运行代码时不应该出现分段错误吗?