小编Den*_*nis的帖子

使用jQuery拖拽<td>内容

我想使用jQuery及其拖放功能,例如:http: //jqueryui.com/demos/draggable/

在我的例子中,我想对<td>HTML表格的内容进行拖放.例如,使用20x20的表格,以便将<img />标签从单元格移动到另一个单元格.

这很难吗?搜索后我没有看到任何示例.如果你有一个,或者你可以告诉我如何处理,我会很酷!

html jquery drag-and-drop html-table

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

在libpcap pcap_loop()回调中传递参数

因为我想使用libpcap和一个小型C程序进行一些测试,所以我试图将结构从main()传递给got_packet()。阅读libpcap教程后,我发现了这一点:

pcap_loop()的原型如下:

int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
Run Code Online (Sandbox Code Playgroud)

最后一个参数在某些应用程序中很有用,但是很多时候只是将其设置为NULL。假设除了pcap_loop()发送的参数外,我们还有自己希望发送给回调函数的参数。这就是我们要做的。显然,您必须强制转换为u_char指针,以确保结果正确到达该指针。稍后我们将看到,pcap利用一些非常有趣的方式以u_char指针的形式传递信息。

因此,据此,可以使用pcap_loop()的参数编号4在got_packet()中发送结构。但是尝试之后,我得到了一个错误。

这是我的(错误的)代码:

int main(int argc, char **argv)
{
 /* some line of code, not important */

 /* def. of the structure: */
 typedef struct _configuration Configuration;
 struct _configuration {
   int id;
   char title[255];
 };

 /* init. of the structure: */
 Configuration conf[2] = {
   {0, "foo"},
   {1, "bar"}};

 /* use pcap_loop with got_packet callback: */
 pcap_loop(handle, num_packets, got_packet, &conf);
}

void got_packet(u_char *args, const struct pcap_pkthdr …
Run Code Online (Sandbox Code Playgroud)

c libpcap

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

在C程序中包含源文件

如何在这个小程序中包含foo.c的foo()函数(对不起我的noob问题):

在我的foo.h文件中:

/* foo.h */
#include <stdio.h>
#include <stdlib.h>

int foo(double largeur);
Run Code Online (Sandbox Code Playgroud)

在foo.c中:

/* foo.c */
#include <stdio.h>
#include <stdlib.h>
#include "foo.h"

int foo(double largeur)
{
  printf("foo");
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

在main.c:

/* main.c */
#include <stdio.h>
#include <stdlib.h>
#include "foo.h"

int main(int argc, char *argv[])
{
  printf("Avant...");
  foo(2);
  printf("Apres...");
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

编译后:

$ gcc -Wall -o main main.c

我收到此错误:

未定义的符号:"_ foo",引用自:ccerSyBF中的_main.l ld:未找到符号collect2:ld返回1退出状态

谢谢你的帮助.

c

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

仅列出常规文件(无目录)问题

你知道为什么这个程序没有列出某些文件,即使它们是"常规"的吗?:

#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <dirent.h>

int main(void) {
  DIR *dh = opendir("./"); // directory handle
  struct dirent *file; // a 'directory entity' AKA file    
  struct stat info; // info about the file.
  while (file = readdir(dh)) {
    stat(file->d_name, &info);
    printf("note: file->d_name => %s\n", file->d_name);
    printf("note: info.st_mode => %i\n", info.st_mode);
    if (S_ISREG(info.st_mode))
      printf("REGULAR FILE FOUND! %s\n", file->d_name);
  }
  closedir(dh);

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

执行完这个程序后,我得到了这个:

note: file->d_name => .
note: info.st_mode => 16877
note: file->d_name => .. …
Run Code Online (Sandbox Code Playgroud)

c directory posix stat readdir

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

标签 统计

c ×3

directory ×1

drag-and-drop ×1

html ×1

html-table ×1

jquery ×1

libpcap ×1

posix ×1

readdir ×1

stat ×1