我从网上从https://computing.llnl.gov/tutorials/pthreads/上摘下了以下演示
#include <pthread.h>
#include <stdio.h>
#define NUM_THREADS 5
void *PrintHello(void *threadid)
{
long tid;
tid = (long)threadid;
printf("Hello World! It's me, thread #%ld!\n", tid);
pthread_exit(NULL);
}
int main (int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
int rc;
long t;
for(t=0; t<NUM_THREADS; t++){
printf("In main: creating thread %ld\n", t);
rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
if (rc){
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
}
pthread_exit(NULL);
}
Run Code Online (Sandbox Code Playgroud)
但是当我在我的机器上编译它(运行Ubuntu Linux 9.04)时,我收到以下错误:
corey@ubuntu:~/demo$ gcc -o term term.c …
Run Code Online (Sandbox Code Playgroud) 我有一个HTML文件,其中包含以下行:
<div><img src="img1.gif"><br>My Text</div>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用JavaScript选择短语"我的文本",以便我可以更改它.我可以使用lastChild获取包含文本的对象,但无法弄清楚如何获取文本本身的值.
我正在寻找一个如何在C程序中使用realpath函数的示例.我似乎无法在网上或我的任何C编程书中找到一个.
今天晚上我正在阅读一些用C编写的代码,文件顶部是类似函数的宏HASH:
#define HASH(fp) (((unsigned long)fp)%NHASH)
Run Code Online (Sandbox Code Playgroud)
这让我想知道,为什么有人会选择使用类似函数的宏来实现这种函数,而不是将它作为常规的vanilla C函数实现?每种实施的优缺点是什么?
谢谢你!
我正在开发一个用于分类汽车照片的网络应用程序.将向用户呈现各种车辆的照片,并且将被要求回答关于他们所看到的一系列问题.结果将记录到数据库中,进行平均并显示.
我正在寻找算法来帮助我识别经常不与群组投票的用户,这表明他们可能要么不关注照片,要么他们对他们看到的内容撒谎.然后我想要排除这些用户,并重新计算结果,这样我可以用已知的信心来说,这张特定的照片显示的是这样的车辆.
这个问题适用于所有计算机科学人员,在哪里可以找到这样的算法,或者给自己设计这样的算法的理论背景.我假设我将不得不学习一些概率和静力学,也许是一些数据挖掘.一些书籍建议会很棒.谢谢!
PS这些是多项选择题.
所有这些都是很好的建议.谢谢!我希望堆栈溢出有一种方法可以选择多个正确的答案,这样你就可以更多地承认你的贡献!
我有一个代表汽车的 JavaScript 类,它是使用两个参数构造的,代表汽车的品牌和型号:
function Car(make, model) {
this.getMake = function( ) { return make; }
this.getModel = function( ) { return model; }
}
Run Code Online (Sandbox Code Playgroud)
有没有办法验证提供给构造函数的品牌和型号是字符串?例如,我希望用户能够说,
myCar = new Car("Honda", "Civic");
Run Code Online (Sandbox Code Playgroud)
但我不希望用户能够说,
myCar = new Car(4, 5.5);
Run Code Online (Sandbox Code Playgroud) c ×5
javascript ×2
algorithm ×1
constructor ×1
data-mining ×1
function ×1
linux ×1
posix ×1
probability ×1
pthreads ×1
realpath ×1
statistics ×1
symlink ×1
types ×1