小编Mar*_*jus的帖子

在C中返回一个字符串

我正试图char从内存中返回一个数组,我只是得到一些随机值.我无法弄清楚出了什么问题.这是我的代码:

stack.h:

struct node{
    char s[MAX_STRING_SIZE];
    struct node * next;
};

typedef struct {
    struct node * head;
} stack;
Run Code Online (Sandbox Code Playgroud)

stack.c:

char * pop(stack * my_stack){
    if (my_stack->head == NULL){
        printf("Stack is empty.");
        exit(0);
    } else {
        struct node * tmp = my_stack->head;
        char * s = tmp->s;

        my_stack->head = my_stack->head->next;

        free(tmp);

        return s;
    }
}
Run Code Online (Sandbox Code Playgroud)

main.c中:

char * s2 = pop(&my_stack);
printf("%s\n", s2);
Run Code Online (Sandbox Code Playgroud)

这会向控制台打印一些随机值.我检查并正确删除内存中的节点.如何正确返回此字符串?

c dynamic

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

如果找不到要返回的对象,我应该从方法返回什么?

这是我的方法:

public Book getBook(String title, String author){
    for (int i = 0; i < listOfBooks.size(); i++){
        Book book = listOfBooks.get(i);
        if (book.getTitle() == title && book.getAuthor() == author){
            return book;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果在listOfBooks中找不到该书,我应该返回什么?

java

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

两个不同脚本标记中的相同变量

这是我的第一个标签

<script type="text/javascript"> 
$(document).ready(function () {

    // some code

    var showWarning = true;

    // more code

});
</script>
Run Code Online (Sandbox Code Playgroud)

然后我有另一个脚本标记:

<script type="text/javascript">
    function submitFormLink(){
        document.getElementById('vacationApplicationForm').action = '<c:url value="/preview-pdf"/>';
        document.getElementById('vacationApplicationForm').method = 'POST';
        document.getElementById('vacationApplicationForm').submit();
    }
    function submitFormButton(){
        if (showWarning == true){
            alert("hi");
        }
        document.getElementById('vacationApplicationForm').action = '';
        document.getElementById('vacationApplicationForm').method = 'POST';
        document.getElementById('vacationApplicationForm').submit();
    }
 </script>
Run Code Online (Sandbox Code Playgroud)

我得到一个错误,说showWarning是未定义的.我在同一窗口中读到变量全局变量.那么我做错了什么?

javascript

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

easy_install ValueError:错误的编组数据(未知类型代码)

我正试图在孤立的环境中进行扩建,我得到了这个错误:

ValueError: bad marshal data (unknown type code)
An error occurred when trying to install djangorestframework-csv 1.3.3. Look above this message for any errors that were output by easy_install.
While:
  Installing django.
  Getting distribution for 'djangorestframework-csv'.
Error: Couldn't install: djangorestframework-csv 1.3.3
make: *** [bin/django] Error 1
Run Code Online (Sandbox Code Playgroud)

我试过谷歌搜索,发现5天前报告了这个完全相同的问题:

https://github.com/mjumbewu/django-rest-framework-csv/issues/18

尝试时也会发生此错误

easy_install djangorestframework-csv==1.3.3
Run Code Online (Sandbox Code Playgroud)

经过一段时间的谷歌搜索后,我发现当出现错误的.pyc文件时会发生此错误.

报告此问题的人说他通过删除pycache解决了这个错误.我尝试搜索pycache并删除所有被调用的文件夹,__pycache__但它没有帮助.任何想法如何解决这个问题?

python makefile buildout easy-install

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

如何在表单中使用图像?

我有三张图片:

<img src="{% static "img/lt.png" %}" />
<img src="{% static "img/en.png" %}" />
<img src="{% static "img/ru.png" %}" />
Run Code Online (Sandbox Code Playgroud)

我需要它们在表单中,但我希望没有提交按钮 - 当用户点击图像时表单被提交.可能吗 ?我怎样才能做到这一点 ?

html javascript css

-10
推荐指数
1
解决办法
136
查看次数

标签 统计

javascript ×2

buildout ×1

c ×1

css ×1

dynamic ×1

easy-install ×1

html ×1

java ×1

makefile ×1

python ×1