X-pop3-spooler: POP3MAIL 2.1.0 b 4 980420 -bs- Message-Id: <3.0.32.19980711235055.0097bda0@xs4all.nl> X-Sender: diep AT xs4all DOT nl X-Mailer: Windows Eudora Pro Version 3.0 (32) Date: Sat, 11 Jul 1998 23:50:57 +0100 To: Tuukka Toivonen From: Vincent Diepeveen Subject: Re: weird things of gcc Cc: beastium-list AT Desk DOT nl Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: Marc Lehmann Status: RO X-Status: A Content-Length: 1670 Lines: 52 At 12:47 AM 7/13/98 +0300, you wrote: >On Sat, 11 Jul 1998, Vincent Diepeveen wrote: > >>first of all, why doesn't gcc have a predefined function like msvc++ have >>called: >> max() and min()? > >Ask why msvc++ has it. If it isn't ANSI C there is absolutely no reason >why gcc should have it (no, i havent checked ANSI C specs). > >Anyway, just insert this code in top of your program: > >#ifndef max >#define max(a,b) ((a) > (b) ? (a) : (b)) >#endif >#ifndef min >#define min(a,b) ((a) < (b) ? (a) : (b)) >#endif Yes i did this in my header file now. but using a #if Unix, as i need to define unix in my program. >>int ReturnFloepWindow(char *sOut) { >> printf("%s\n",sOut); >> gets(sOut); >> return(true); >>} > >>"the 'gets' function is dangerous and should not be used." > >The gets() function does not check how long string the user >gives; if it is too long string and does not fit in sOut >array, you have a bug in your program (memory corruption). 120 bytes. Why would it give memory corruption, knowing it's just a pointer to an existing array of 120 bytes? I only give it an address where it needs to put the small string. What's wrong with this, and yes i don't want it to check how long the string is, it just must put the string at that address , that's it! >You should use instead fgets() with stdin argument that checks >the given string length. >-- >| Tuukka Toivonen [PGP public key >| Homepage: http://www.ee.oulu.fi/~tuukkat/ available] >| Try also finger -l tuukkat AT ee DOT oulu DOT fi >| Studying information engineering at the University of Oulu >+----------------------------------------------------------- > >