home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 243,160 of 243,242   
   Janis Papanagnou to Keith Thompson   
   Re: printf and time_t   
   06 Feb 26 09:51:07   
   
   From: janis_papanagnou+ng@hotmail.com   
      
   On 2026-02-06 06:10, Keith Thompson wrote:   
   > Bart  writes:   
   >   
   >> If I compile this code with 'gcc -Wall -Wextra -Wpedantic':   
   >>   
   >>    #include    
   >>   
   >>    int main() {   
   >>        int a = -1;   
   >>        printf("%u", a);   
   >>    }   
   >>   
   >> it says nothing. The program displays 4294967295 instead of -1.   
      
   Yes. You instruct 'printf' with '%u' to interpret and display it   
   (the variable 'a') as unsigned. ('-1' is not an unsigned numeric   
   representation.) - I wonder what you are thinking here.   
      
   >   
   > The behavior is unsurprising.  The lack of a warning is very mildly   
   > inconvenient.   
      
   Indeed unsurprising. And I even don't see any inconvenience given   
   that even an initialized declaration of 'unsigned a = -1;' is not   
   considered a problem in "C". I rather learned that to be a useful   
   code pattern when programming in "C".   
      
   Janis   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca