How to enable %zu ??

This is a discussion on How to enable %zu ?? within the C Programming forums, part of the General Programming Boards category; Hello, Dear all. I am using Dev-C++ 4.9.9.2. My question is how to enable %zu . The following program prints ...

  1. #1
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    212

    How to enable %zu ??

    Hello, Dear all. I am using Dev-C++ 4.9.9.2. My question is how to enable %zu .
    The following program prints `zu' instead of an integer, which is what I expect.
    How can I set up Dev-C++ to support %zu ?

    Code:
    #include <stdio.h>
    
    int main( void )
    {
        printf( "%zu", sizeof(int) );
        
        getchar();
    }

  2. #2
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    I don't think those are supported in printf like that. Why not just use %d instead like this:
    Code:
    printf("%d",sizeof(int));
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  3. #3
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    C99 introduced %z for proper output of size_t types, just in case %d isn't appropriate. I'm not familiar with Dev-C++, perhaps it doesn't come with a C99 library?

  4. #4
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    To my knowledge it does not come with it.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  5. #5
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    if you are using a feature of C99, make sure your file type is .c and not .cpp, also make sure your compiler supports it of course.

  6. #6
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    212
    Yes, my file type is .c . But I'm not sure whether Dev-C++ is fully support C99 or not.

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    212
    I found that gcc3.2 supports %zu.
    So I guess if I set it up correctly, Dev-C++ will support %zu too.

  9. #9
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by Dave_Sinkula
    Maybe:
    [...] the "%zu" format is new in C99. That means that some systems don't yet support it. (Incidentally, there is no "gcc printf man page". printf is part of the runtime library; gcc is just the compiler. gcc typically uses the native runtime library on a given system, so having a current version of gcc is no guarantee that printf() supports "%zu".)
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enable core dumping
    By steve1_rm in forum C Programming
    Replies: 3
    Last Post: 01-21-2009, 09:41 AM
  2. how to enable a button
    By nineofhearts in forum C++ Programming
    Replies: 1
    Last Post: 01-18-2006, 10:58 AM
  3. Disable and enable of lights
    By bludstayne in forum Game Programming
    Replies: 7
    Last Post: 06-03-2004, 11:30 AM
  4. How to enable c++ highlight in vim?
    By MelaOS in forum Tech Board
    Replies: 1
    Last Post: 01-15-2004, 06:39 AM
  5. enable disabled menu item.
    By Apache in forum Windows Programming
    Replies: 7
    Last Post: 02-12-2002, 07:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21