文件描述符問題 在上面的內存問題表中,對于大多數的內存問題來說,相信對于熟悉 C/C++ 的 程序員 ,并不陌生。有一些關于 Watchpoint 和文件描述符的內容,可能會讓你看得比較模糊,對于 Watchpoint ,我會在后面講述。這一節,我就一個示例" name="description" />

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • C/C++內存問題檢查利器—Purify文件描述符問題

    發表于:2009-04-20來源:作者:點擊數: 標簽:符問題利器文件Purify內存
    MI LY: 宋體"> 文件描述符問題 在上面的內存問題表中,對于大多數的內存問題來說,相信對于熟悉 C/C++ 的 程序員 ,并不陌生。有一些關于 Watchpoint 和文件描述符的內容,可能會讓你看得比較模糊,對于 Watchpoint ,我會在后面講述。這一節,我就一個示例

    MILY: 宋體">文件描述符問題

    在上面的內存問題表中,對于大多數的內存問題來說,相信對于熟悉C/C++程序員,并不陌生。有一些關于Watchpoint和文件描述符的內容,可能會讓你看得比較模糊,對于Watchpoint,我會在后面講述。這一節,我就一個示例說一說文件描述述問題是如何產生的,并由此介紹一下Purify的一些特性。

     

    先查看下面這段程序:

     

    #include <stdio.h>

     

    main()

    {

        FILE* fp;

        int num;

     

        fp = fopen("./test.txt", "r");

        if ( fp == NULL){

            perror("Error:");

            exit(-1);

        }

     

        fscanf(fp, "%d", &num);

        if ( num < 0 ){

           printf("Error: the num should be greater than 0!\n");

           exit(-1);

        }

     

        fclose(fp);

    }

     

    在當前目錄下建一個test.txt的文件,并設置其內容為-20。使用Purify編譯并運行程序:

    >  purify gcc -g -o testfd testfd.c

    Purify 2003.06.00 Solaris 2 (32-bit) Copyright (C) 1992-2002 Rational Software Corp.  All rights reserved. 

    Instrumenting: ccqqF6pY.o  Linking

     

    >./testfd

     

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>