Mail Archives: pgcc/1998/07/12/22:00:35
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 -