Thread: A memory leak

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,127
    Actually, there is one minor correction I would make besides the my other reccmendations:
    Code:
    printf("%u is not betweem 1 and %u.\n", count, MAXNUMS);
    
    // Should be:
    
    printf("%u is not betweem 1 and %d.\n", count, MAXNUMS);
    The #define is interpreted by the compiler as an "int", not an "unsigned int".

    It doesn't result in an error, but when I use "cppcheck" on Linux, it does report as a warning.

    Only ran cppcheck on Linux. It should be available for MacOS, along with others.

    ccpcheck output:
    Code:
    foo.c:52:10: warning: %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'. [invalidPrintfArgType_uint]
             printf("%u is not betweem 1 and %u.\n", count, MAXNUMS);
             ^
    Last edited by rstanley; 03-25-2024 at 08:04 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory leak
    By *nick in forum Windows Programming
    Replies: 8
    Last Post: 09-17-2012, 06:15 PM
  2. Possible memory leak?
    By 127.0.0.1 in forum C Programming
    Replies: 21
    Last Post: 05-02-2011, 04:53 PM
  3. Replies: 2
    Last Post: 09-28-2006, 01:06 PM
  4. Is this a memory leak?
    By jasonhv in forum C++ Programming
    Replies: 5
    Last Post: 10-20-2005, 08:37 PM
  5. How is this a Memory Leak?
    By Cheeze-It in forum C++ Programming
    Replies: 4
    Last Post: 05-24-2002, 04:59 AM

Tags for this Thread