Chinaunix首页 | 论坛 | 博客
  • 博客访问: 388255
  • 博文数量: 70
  • 博客积分: 1919
  • 博客等级: 上尉
  • 技术积分: 1179
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-24 20:05
文章分类

全部博文(70)

文章存档

2014年(2)

2013年(29)

2012年(20)

2011年(1)

2010年(13)

2009年(5)

分类:

2012-11-03 12:12:07

原文地址:破解无线密码 作者:kouyanghao

累了闲得无聊,看到一篇很好的文章,以后可能会用到 分享下:
1.
 
2.
 
3.
 
  • 113. 如果使用任何一种”w”模式打开一个已有的文件,文件内容将被删除,以便程序以一个空文件开始操作。

4.

  •  简单的文件压缩程序:

  • // reducto.c -- reduces your files by two-thirds!

    #include

    #include     // for exit()

    #include     // for strcpy(), strcat()

    #define LEN 40

     

    int main(int argc, char *argv[])

    {

        FILE  *in, *out;   // declare two FILE pointers

        int ch;

        char name[LEN];    // storage for output filename

        int count = 0;

       

    // check for command-line arguments

        if (argc < 2)      

        {

             fprintf(stderr, "Usage: %s filename\n", argv[0]);

             exit(1);

        }

    // set up input

        if ((in = fopen(argv[1], "r")) == NULL)

        {

            fprintf(stderr, "I couldn't open the file \"%s\"\n",

                    argv[1]);

            exit(2);

        }

    // set up output   

        strncpy(name,argv[1], LEN - 5); // copy filename

        name[LEN - 5] = '\0';

        strcat(name,".red");            // append .red 

        if ((out = fopen(name, "w")) == NULL)

        {                       // open file for writing

            fprintf(stderr,"Can't create output file.\n");

            exit(3);

        }

    // copy data

        while ((ch = getc(in)) != EOF)

            if (count++ % 3 == 0)

                putc(ch, out);  // print every 3rd char

    // clean up   

        if (fclose(in) != 0 || fclose(out) != 0)

            fprintf(stderr,"Error in closing files\n");

       

        return 0;

    }

阅读(852) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~