--------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3H00025 Date: 03/13/98 From: ROGER SCUDDER Time: 01:16am \/To: TOM TORFS (Read 2 times) Subj: Type detection Hello Tom. 11 Mar 98 20:56, Tom Torfs wrote to Roger Scudder: RS>> If I pass a pointer to struct to a function and that struct RS>> contains a member that is a void pointer and could be pointing to RS>> any data type, is there a way to have the function determine the RS>> type that the void pointer is pointing to? TT> You could do something like this: TT> enum data_type {T_INT,T_FLOAT,T_WHATEVER}; TT> struct some_struct { TT> enum data_type ptr_type; TT> void *ptr; TT> }; That is basically what I did end up doing. I had hoped that there was another, less kludged way to do it. The reason being that it takes away from the elegance obtained from the use of the void pointer. -Roger ... I don't suffer from insanity, I enjoy every minute of it. --- Msged 4.20 beta 3 * Origin: Hodge-Podge Support BBS, Upper Darby, Pennsylvania, USA (1:273/404@fidonet) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3H00026 Date: 03/13/98 From: ROGER SCUDDER Time: 01:22am \/To: PHILIP LINDBORG (Read 2 times) Subj: Ehhr.. XMS..? Hello Philip. 10 Mar 98 19:41, Philip Lindborg wrote to All: PL> The problem is that i use farcalloc() to allocate memory, and this PL> function doesn't give me enoung memory.... I think it is EMS or XMS memory PL> I should use... but how do I allocate XMS or EMS (or whatever it should be) PL> memory to my program, and how do I read/write from/to it? PL> I have a Borland C++ 3.1 compiler (DOS). Now that a 32bit OS is a common reality for most people, I don't think many developers are writing games that way anymore. I think you should put your energy into learning to write games that run under Windows 95 where you don't have to be concerned with such things. Since you are a student, you qualify for a major discount on a 32bit compiler. Oh, yeah. There is some sample code for EMS/XMS programming in Snippets. -Roger ... Generic Tagline v5: [ ]Flame Moderator [ ]Flame Sysop [X]Flame user. --- Msged 4.20 beta 3 * Origin: Hodge-Podge Support BBS, Upper Darby, Pennsylvania, USA (1:273/404@fidonet) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3H00027 Date: 03/13/98 From: ROGER SCUDDER Time: 01:41am \/To: DARIN MCBRIDE (Read 2 times) Subj: CRC model [9/12] Hello Darin. 12 Mar 98 08:03, Darin McBride wrote to Bob Stout: BS>> Thanks - it all worked great! DM> This will be on-topic only insofaras I'm asking about the echo's DM> moderation. Who is supposed to tell Bob that "thank-you messages" are DM> off-topic, the moderator (Tom) or the zone's co-moderator (Roger)? :-) IMHO - a thank you for a Snippets submission is a little different than a newbie writing a thank you for help. For one thing newbies usually send one to everybody who replies to them. And, besides. Bob's been here since dirt and he's a major contributor. If that don't get you a little leeway, then I'd like to know what does. DM> Just curious.... yeah.... well, don't forget where that got the cat. -Roger ... I don't suffer from insanity, I enjoy every minute of it. --- Msged 4.20 beta 3 * Origin: Hodge-Podge Support BBS, Upper Darby, Pennsylvania, USA (1:273/404@fidonet) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3I00000 Date: 03/12/98 From: TOM TORFS Time: 08:11pm \/To: BILL BIRRELL (Read 2 times) Subj: Avoid disaster * Reply to a message in personal_mail. Bill Birrell wrote in a message to Tom Torfs: > Just a minor nitpick: C standard library functions > should be lowercase, even when they're at the start of > a sentence :-) BB> Wrong, Tom! BB> In a program, yes; in prose, no. I must have been confused then. In Dutch we have the habit of writing case-dependant things like chemical & physical symbols etc. always in their proper case, no matter where they are in the sentence, and C identifiers seem to fall into this category as well. It's not so important anyway, as long as there can be no confusion (for example, if you tell a beginner: "Free() is the function you need here." and he comes back with "My linker reports _Free() is an undefined reference!"). :-) greetings, Tom tomtorfs@village.uunet.be --- timEd/2 1.10+ * Origin: 80X86 BBS 32-15-24.62.32 V.34/V.FC (24h/24h) (2:292/516) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3I00001 Date: 03/13/98 From: TOM TORFS Time: 06:49pm \/To: ALL (Read 2 times) Subj: Herman Schonfeld Hello All! Herman Schonfeld is back with us: I have just lifted his ban. Any comments/discussions on this subject should be done via private mail. greetings, Tom tomtorfs@village.uunet.be --- timEd/2 1.10+ * Origin: 80X86 BBS 32-15-24.62.32 V.34/V.FC (24h/24h) (2:292/516) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3I00002 Date: 03/13/98 From: TOM TORFS Time: 06:53pm \/To: JOHN DUMAS (Read 2 times) Subj: Avoid disaster John Dumas wrote in a message to 0+=ALL: JD> I know what free does but how does it do it. JD> It has the starting address of the passed variable &variable[0]. JD> How does it know where it ends ??? Usually every memory block allocated is preceded by an info block, comparable to the DOS memory control block, which contains amongst others the size of the block. That's why you have to be careful what you free(): the malloc() internal data structures might easily get corrupted. JD> It just doesn't free up to the first '\0', it frees it all. Right, if it would only free up to the first '\0' the implementation would be badly broken. greetings, Tom tomtorfs@village.uunet.be --- timEd/2 1.10+ * Origin: 80X86 BBS 32-15-24.62.32 V.34/V.FC (24h/24h) (2:292/516) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3I00003 Date: 03/10/98 From: GAINES WRIGHT Time: 07:12am \/To: JOHN DUMAS (Read 2 times) Subj: Avoid Disaster JD> For still learning programmers like myself the self made bug that JD> drives me to distraction is intermittantly over filling or over JD> reading an array or string. JD> char string[4]; JD> string="OUCH"; This is not legal 'C', but I get your drift. :-)> JD> I need a function put in C like. JD> char string[4]; JD> if( CheckLimit( string,lenstr("OUCH")) JD> ^^^^^^^^^^ If you declare your string as an array then you can use the sizeof() operator to determine the number of characters that can be safely written. Sizeof() can only be used in this way in the same function that the array is declared. If you need to pass a pointer to the string to another function, you will have to also pass the sizeof() the array as a separate parameter. For example, a safe string copy function: #include #include char *safe_strcpy(char *dest, char *source, int len) { dest[--len]='\0'; return(strncpy(dest, source, len)); } void main(void) { char source[11]="1234567890", string[5]; puts(safe_strcpy(string, source, sizeof(string))); } * SLMR 2.1a * Heisenburg might of slept here. --- FMailX32 1.22 * Origin: The Logic Gate BBS (813) 831-8125 Tampa, Fl (1:377/49) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3I00004 Date: 03/06/98 From: NAVIN PAI Time: 12:42pm \/To: DONALD BOWERS (Read 2 times) Subj: Re: Has anyone? On 03-02-98 17:15, DONALD BOWERS & JOHN DUMAS were talking about Re: Has anyone? JD>-=> Quoting Victor Kemp to John Dumas <=- JD> VK> Of course you can easily modify command.com to DB>Speaking of modifying command.com, a friend of mine modified his DB>command.com so it said "Starting Windoze 95" instead of the usual DB>"Starting Windows 95". He distributed it, too. Although I do not know DB>where... no need to look for the modified command.com. even if u got it, u'll still get the message "Starting Windows 95" instead of getting the message "Starting Windoze 95". becuz the message is embedded in the file "io.sys" rather than in the file command.com. well if u want to change the message, follow the steps. 1. get any binary file editor. 2. reset the read only and hidden attributes of io.sys. 3. load the file in the editor and search for the string "Starting Windows 95". 4. after locating it change the message to whatever u like. 5. take care not to overwrite the adjacent bytes as this may have unpredictable results. 6. save the file. 7. reset the file attributes to it's original value. 8. and voila the next time u boot u will get it displayed in ur system. bye, |\ |_ | \ | | * | \|~|\/||\|, Nagpur, India ___ * PW * Properly trained, a human can be dog's best friend. --- Maximus/2 3.01 * Origin: Kalptaru Net India. http://www.kalptaru.com . (6:606/31) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3I00005 Date: 03/06/98 From: NAVIN PAI Time: 12:42pm \/To: JOHN DUMAS (Read 2 times) Subj: Re: Has anyone? On 03-02-98 17:15, DONALD BOWERS & JOHN DUMAS were talking about Re: Has anyone? JD>-=> Quoting Victor Kemp to John Dumas <=- JD> VK> Of course you can easily modify command.com to DB>Speaking of modifying command.com, a friend of mine modified his DB>command.com so it said "Starting Windoze 95" instead of the usual DB>"Starting Windows 95". He distributed it, too. Although I do not know DB>where... no need to look for the modified command.com. even if u got it, u'll still get the message "Starting Windows 95" instead of getting the message "Starting Windoze 95". becuz the message is embedded in the file "io.sys" rather than in the file command.com. well if u want to change the message, follow the steps. 1. get any binary file editor. 2. reset the read only and hidden attributes of io.sys. 3. load the file in the editor and search for the string "Starting Windows 95". 4. after locating it change the message to whatever u like. 5. take care not to overwrite the adjacent bytes as this may have unpredictable results. 6. save the file. 7. reset the file attributes to it's original value. 8. and voila the next time u boot u will get it displayed in ur system. bye, |\ |_ | \ | | * | \|~|\/||\|, Nagpur, India ___ * PW * Properly trained, a human can be dog's best friend. --- Maximus/2 3.01 * Origin: Kalptaru Net India. http://www.kalptaru.com . (6:606/31) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3I00006 Date: 03/07/98 From: NAVIN PAI Time: 08:35am \/To: JOHN RICHARDSON (Read 2 times) Subj: what's happening On 03-01-98 14:30, John Richardson & Carlton Walters were talking about what's happening JR>Hi Carlton, Hi John JR> signed short var1; JR> unsigned short var2; JR>and then do: JR> var1 = var2 = %111111111111; /* I'm can't remember off hand the JR> correct way to indicate a binary JR> value in C this is my best guess :) JR> */ JR>var1 would contain the value -32767 whereas var2 would contain 65535. JR>A signed variable is usually the default so there is mostly JR>no need to specify 'signed'. to represent a binary no in c there is no other way than to convert it into a hexadecimal no and then represent it using hexadecimal notation. even if ur representation is considered to be hypothetically correct the contents of var1 and var2 would be same i.e. 4095. to get the values of -32767 and 65535 u should add four more one's, to get, in all 16bits. now it's just 12 bits. bye, |\ |_ | \ | | * | \|~|\/||\|, Nagpur, India ___ * PW * Fun, fun, fun, 'til her daddy takes her Blue Wave away! --- Maximus/2 3.01 * Origin: Kalptaru Net India. http://www.kalptaru.com . (6:606/31)