小编cxz*_*xzp的帖子

不知道为什么编译器会抱怨......函数 strchrnul 的隐式声明

这是我的代码:

#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

static int valid_line(char *cur_line) {
    if (*cur_line == '#') {
        return 0;
    }

    char *end = strchrnul(cur_line, '#');

    while(end > cur_line && isspace(*end)) end--;
    return (!(*cur_line == *end));
}
Run Code Online (Sandbox Code Playgroud)

我正在通过这条线并摆脱前导和尾随空格以及“#”(包括“#”)之后出现的任何内容。

我的编译器是这样说的:

parser.c:20:2: warning: implicit declaration of function ‘strchrnul’ [-Wimplicit-    function-declaration]
parser.c:20:14: warning: initialisation makes pointer from integer without a cast [enabled by default]
Run Code Online (Sandbox Code Playgroud)

即使我string.h上面有。

有人可以解释一下。

c compiler-errors header-files compiler-warnings

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

c中从void*转换为int的说明

在我的代码我有:

int number_compare(void *val1, void *val2) {
    if (*(int*) val1 < *(int*s) val2) {
Run Code Online (Sandbox Code Playgroud)

所以基本上从void*转换为int我必须转换*(int*).

这有效,并给我正确的结果,有人可以告诉我为什么,或指向我解释它的线程.我已经看了,找不到我理解的答案.

c type-conversion

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

您是否应为每个不同的呼叫创建新的异步任务或使用相同的呼叫

所以我有一个应用程序,将使多个HTTP Post/Gets

EG登录,getThisData,getThatData,sendThis,sendThat

有一个单独的AsyncTask来处理每一个更好

或一个异步任务,并与开关不同的方式处理他们onPostExecutedoInBackground

干杯

android http android-asynctask

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

editText框的计时器:只有创建视图层次结构的原始线程才能触及其视图

我正在尝试使用edittext boxvibrate并在输入错误密码时立即更改颜色

final Drawable oldBackground = findViewById(R.id.email).getBackground();
TimerTask timerTask = new TimerTask() {
    @Override
    public void run() {
        MainActivty.this.findViewById(R.id.password).setBackground(oldBackground);
        MainActivty.this.findViewById(R.id.email).setBackground(oldBackground);
    }
};


Toast.makeText(MainActivty.this , valArray.get(0).toString(), Toast.LENGTH_SHORT).show();
findViewById(R.id.password).setBackgroundColor(Color.RED);
findViewById(R.id.email).setBackgroundColor(Color.RED);
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(500);Timer timer = new Timer();
timer.schedule(timerTask, 1000);
Run Code Online (Sandbox Code Playgroud)

android timer timertask

3
推荐指数
2
解决办法
3687
查看次数

C是否通过<<或>>位移来保持进位?

我读到C保持从移位进出,它可以在特定于处理器的.h中找到.

这是真的,我应该使用它吗?或者应该自己计算出结转位?

c bit-shift carryflag

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

关于C中字符比较的Segfault

我有以下代码:

void click(int x, int y, zbar_window_t *window, ZBarGtk *self) {
    char* response = handle_click_events(x, y, window);
    printf("RESPONSE + %s\n", response);
    printf("%c\n", response[0]);
    if (response[0] == "0") {                                 //CRASHES HERE
        printf("inside \n");
        printf("%s\n", response++);
        g_signal_emit(self, self->enumACTIVE, 0, -1, response++);
    }
    else {
        g_signal_emit(self, self->enumACTIVE, 0, -1, response++);
    }
}
Run Code Online (Sandbox Code Playgroud)

它继续在规定的线上崩溃.

c string char segmentation-fault

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

POpen使用字符串但不是变量

我可以得到以下工作:

fp = popen("curl http://192.168.0.144:8000/adder?wsdl", "r");
Run Code Online (Sandbox Code Playgroud)

但是,当我这样尝试时:

char* cmd;
strcpy(cmd, "curl http://");
strcat(cmd, qrdata->ip_addr);
strcat(cmd, ":8000/adder?wsdl");

fp = popen(cmd, "r");
Run Code Online (Sandbox Code Playgroud)

发生分段错误.

c curl popen segmentation-fault

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