小编Jat*_*tin的帖子

这个基本的JavaScript代码有什么问题?

我正在尝试编写基本的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)

第一次点击时颜色变为黄色,但再次点击时颜色不会变为粉红色.我无法弄清楚这个问题.

javascript javascript-events

0
推荐指数
1
解决办法
83
查看次数

设置github时SSH密钥设置问题

我按照教程在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.

git version-control github ssh-keys permission-denied

0
推荐指数
1
解决办法
366
查看次数

C中动态大小的数组

这是我正在使用的代码片段:

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;然后再次调试代码就行了.

为什么会这样?(我想要做的是创建一个动态大小的数组.)

c c++ arrays pointers

0
推荐指数
1
解决办法
224
查看次数

使用`delete`从链表中删除节点

以下是从单个链接列表尾部删除元素的代码的一部分:

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)

这里headtail是指向LL的第一和最后一个元素,分别.

在我们设置if之后的上面的块delete headhead = tail = 0.

但是在我们删除之后,我们head如何才能将它的价值设定为某种东西?(NULL在这种情况下)

c++ pointers linked-list delete-operator

0
推荐指数
1
解决办法
918
查看次数

删除 C++ 中的指针:“删除 p”是什么意思?

#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 时?

运行代码时不应该出现分段错误吗?

c++ pointers delete-operator

-3
推荐指数
1
解决办法
1970
查看次数