有谁知道如何配置lighttpd来处理普通的CGI可执行文件,在这种情况下用C语言编写?我编译了一个测试程序(test.cgi)并将其放在$ HOME/public_html/cgi-bin中.我还启用了CGI模块lighty-enable-mod cgi并重新启动了Web服务器.仍然,在请求http://localhost/~august/cgi-bin/test.cgi时,程序不会运行,而是被视为静态文件.顺便说一下,这是我的测试程序:
#include <stdio.h>
int main(void)
{
printf("Content-type: text/plain\n\n");
puts("test...");
return 0;
}
Run Code Online (Sandbox Code Playgroud) 为什么这个打印在主打印时为0,但在strcmp函数内打印时为6?
7 int main()
8 {
9 char* str = "test string";
10 char* str2 = "test strong";
11 //printf("string length = %d\n",strlen(str));
12
13 int num = strcmp(str,str2);
14
15 printf("num = %d\n",num);
16 }
29 int strcmp(char* str, char* str2)
30 {
31 if(*str == '\0' && *str2 == '\0')
32 return 0;
33 if(*str2 - *str == 0)
34 {
35 strcmp(str+1,str2+1);
36 }
37 else
38 {
39 int num = *str2 - *str;
40 cout …Run Code Online (Sandbox Code Playgroud) 对于存储在x中的double值,缓冲区需要在下面的函数调用中有多大?
sprintf(buffer, "%.*g", DBL_DIG, x);
Run Code Online (Sandbox Code Playgroud) 如果只有一个属性height或width为img元素设置,大多数浏览器似乎保持图像的比例.
这是来自HTML 4.01参考:
当对象是图像时,它被缩放.用户代理应尽力缩放对象或图像以匹配作者指定的宽度和高度.
http://www.w3.org/TR/html401/struct/objects.html#edef-IMG
浏览器不均匀地缩放图像,只改变图像的高度或宽度是不是错了?
更新2015-08-12:Dillo(版本3.0.4)是一个浏览器的示例,如果仅设置高度或仅设置宽度,则不保留图像的比例.
我正在尝试用 C 语言实现一个简单的 X11 按键抓取器,用于使用 Alt-Tab 等进行窗口切换。我可以使用函数XSelectInput来处理特定窗口的键盘事件:
XSelectInput(display, window, KeyPressMask | KeyReleaseMask);
Run Code Online (Sandbox Code Playgroud)
无论聚焦哪个窗口,如何接收“全局”键盘事件?
我正在尝试使C编译器clang进入ANSI C89模式,但没有成功.
这是一个示例会话:
$ cat t.c
#include <stdio.h>
int main(void)
{
puts(__FUNCTION__);
return 0;
}
$ gcc -pedantic -std=c89 -Wall t.c
t.c: In function ‘main’:
t.c:5:7: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
puts(__FUNCTION__);
^~~~~~~~~~~~
$ clang -pedantic -std=c89 -Wall t.c
$ clang --version
clang version 3.8.1-24 (tags/RELEASE_381/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Run Code Online (Sandbox Code Playgroud)
如您所见,该clang命令完成时没有警告.有没有我在这里缺少的命令选项?
我正在尝试在Eclipse e4应用程序中获取视图部分的实例,但我找不到PlatformUI类.自Eclipse 3以来名称是否已更改,或者它位于不同的包中?
是否可以直接将整数SEXP参数转换为整数而无需先将其转换为整数向量?
例:
#include <Rcpp.h>
SEXP f(SEXP n)
{
Rcpp::IntegerVector n_vec(n);
int n1 = n_vec[0];
...
return R_NilValue;
}
Run Code Online (Sandbox Code Playgroud) 当我用GCC 4.9.2编译下面的程序时,我得到以下警告:从不兼容的指针类型传递'P'的参数1.但是,我没有看到该程序有任何问题.有线索吗?
typedef int Row[10];
void P(const Row A[])
{
}
int main(void)
{
Row A[10];
P(A);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
以下是GCC到stderr的完整输出:
test.c: In function ‘main’:
test.c:12:4: warning: passing argument 1 of ‘P’ from incompatible pointer type
P(A);
^
test.c:3:6: note: expected ‘const int (*)[10]’ but argument is of type ‘int (*)[10]’
void P(const Row A[])
^
Run Code Online (Sandbox Code Playgroud)
编辑:该程序与Clang 3.5.0和选项完全编译-pedantic -std=c89 -Wall.