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 242,367 of 243,242   
   Michael Sanders to James Kuyper   
   Re: is_binary_file()   
   08 Dec 25 18:02:26   
   
   From: porkchop@invalid.foo   
      
   On Sat, 6 Dec 2025 20:37:22 -0500, James Kuyper wrote:   
      
   > NULL is a macro that expands to a null pointer constant. I think you   
   > mean "null character". This isn't just nit-picking -C is a   
   > case-sensitive language, so it's essential to pay attention to case.   
      
   Of yeah. I'm at the stage of simultaneously getting a lot wrong,   
   a lot right, & that makes my code dangerous at times. I'm slowly   
   getting there.   
      
   > You should return a distinct value for file open failure - a file that   
   > cannot be opened cannot be determined to be either a text or a binary file.   
      
   Noted.   
      
   > You really cannot distinguish with certainty whether a file is a text   
   > file or a binary file based solely upon the contents. A file whose   
   > format is an array of two-byte 2's complement little-endian integers   
   > would normally be considered binary, yet it might happen to contain   
   > integers whose bytes all happen to be printable characters.   
      
   Ah, I want it to be simple, but that's not the case.   
      
   > This implies the use of the isprint() function; the only other   
   > characters you need to handle specifically are '\t', '\n', and ' '.   
   > Since the result returned by isprint() is locale-dependent, the program   
   > should, at least optionally, use setlocale().   
      
   Hmm, now that's a curve-ball I did not see coming! I've got to think   
   about this...   
      
   Paul, thank you for sharing your knowledge, I appreciate your help sir.   
      
   --   
   :wq   
   Mike Sanders   
      
   --- 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