标题:一年中关于C的总结
取消只看楼主
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
结帖率:98.63%
 问题点数:0 回复次数:1 
一年中关于C的总结
#include <pthread.h>
#include <stdio.h>
/* Parameters to print_function.  */
struct char_print_parms
{
    /* The character to print.  */
    char character;
    /* The number of times to print it.  */
    int count;
};
    /* Prints a number of characters to stderr, as given by PARAMETERS,
    which is a pointer to a struct char_print_parms.  */
void* char_print (void* parameters)
{
    /* Cast the cookie pointer to the right type.  */
    struct char_print_parms* p = (struct char_print_parms*) parameters;
    int i;
    for (i = 0; i < p->count; ++i)
    fputc (p->character, stderr);
    return NULL;
}
    /* The main program.  */
int main ()
{
    pthread_t thread1_id;
    pthread_t thread2_id;
    struct char_print_parms thread1_args;
    struct char_print_parms thread2_args;
    /* Create a new thread to print 30,000 ’x’s.  */
    thread1_args.character = ’x’;
    thread1_args.count = 30000;
    pthread_create (&thread1_id, NULL, &char_print, &thread1_args);
    /* Create a new thread to print 20,000 o’s.  */
    thread2_args.character = ’o’;
    thread2_args.count = 20000;
    pthread_create (&thread2_id, NULL, &char_print, &thread2_args);
    return 0;
}
搜索更多相关主题的帖子: character void include cookie number 
2012-01-10 21:28
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
得分:0 
回复 2楼 zaixuexi
楼主把这贴删了吧,一开始不知道怎么发,

The quieter you become, the more you can hear
2012-01-10 22:46



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-359486-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.352383 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved