delorie.com/archives/browse.cgi   search  
Mail Archives: pgcc/1998/07/12/22:00:35

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 <tuukkat AT ees2 DOT oulu DOT fi>
From: Vincent Diepeveen <diep AT xs4all DOT nl>
Subject: Re: weird things of gcc
Cc: beastium-list AT Desk DOT nl
Mime-Version: 1.0
Sender: Marc Lehmann <pcg AT goof DOT com>
Status: RO
X-Status: A
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 <tuukkat AT ee DOT oulu DOT fi>       [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
>+-----------------------------------------------------------
>
>

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019