这是我的代码:
#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上面有。
有人可以解释一下。
在我的代码我有:
int number_compare(void *val1, void *val2) {
if (*(int*) val1 < *(int*s) val2) {
Run Code Online (Sandbox Code Playgroud)
所以基本上从void*转换为int我必须转换*(int*).
这有效,并给我正确的结果,有人可以告诉我为什么,或指向我解释它的线程.我已经看了,找不到我理解的答案.
所以我有一个应用程序,将使多个HTTP Post/Gets
EG登录,getThisData,getThatData,sendThis,sendThat
有一个单独的AsyncTask来处理每一个更好
或一个异步任务,并与开关不同的方式处理他们onPostExecute与doInBackground
干杯
我正在尝试使用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) 我读到C保持从移位进出,它可以在特定于处理器的.h中找到.
这是真的,我应该使用它吗?或者应该自己计算出结转位?
我有以下代码:
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)
它继续在规定的线上崩溃.
我可以得到以下工作:
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)
发生分段错误.