--------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2F00012 Date: 02/10/98 From: TOM TORFS Time: 04:35pm \/To: AUKE REITSMA (Read 1 times) Subj: WARNING MESSAGE - 2 Auke Reitsma wrote in a message to Tom Torfs: TT> If your programs are large enough to make segmentation a PITA, TT> better make them 32-bit. Even for DOS there are little excuses TT> anymore today ;-) AR> Hm ... not sure I agree. If the data causes segmentation problems AR> that is _another_ good reason to look at the used algorithm ... Well, if you have to work with BLOBs like images etc. that must be kept in addressable memory because they need to be accessed quickly, I think segmentation can be a bit of a problem, but the approx. 1MB real/V86 mode limit is more of a problem in that case. Which is why for such applications I would prefer 32 bit. 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: F2F00013 Date: 02/10/98 From: TOM TORFS Time: 04:38pm \/To: JASEN BETTS (Read 1 times) Subj: 32BIT INTEGERS TO 16BIT I Jasen Betts wrote in a message to ROBERT LA FERTE: JB> BTW if you break your ints up into chars there's no "endian-ness" JB> problem that you would otherwise get. Provided you consistently split them up and re-join them, of course. 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: F2F00014 Date: 02/10/98 From: TOM TORFS Time: 04:44pm \/To: PATRICK WOODCOCK (Read 1 times) Subj: Include files PATRICK WOODCOCK wrote in a message to ALL: PW> Does anyone know where I could get include files. I've tried on a PW> BBS but the include files wheren't the ones in my C book. I PW> especially need ones like CONIO.H and GRAPHICS.H as I hope to PW> include nice graphics in my programs. I'm afraid that's impossible, for several reasons: * include files only contain declarations etc., not the actual code (those are usually in libraries) * the include files _and_ libraries are most often compiler-specific * the include and library files are usually copyrighted and may not be freely distributed The solution to your problem is to find some stand-alone libraries to do this. For a great, portable conio.h replacement have a look at Andrew Clarke's VidMgr package (it's in Snippets). For graphics libraries there are many possibilities, free-, share- and payware, depending on just what you require. However, the routines in your book will most likely not be compatible with these. That's why it's a bad idea to buy books that rely on non-standard libraries --- even more so if the compiler you use doesn't support these. 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: F2F00015 Date: 02/10/98 From: VICTOR KEMP Time: 03:24pm \/To: CAREY BLOODWORTH (Read 1 times) Subj: interrupt function NOTE: DCTEdit v0.04 [8] CB> You also need to be very, very careful about any library calls you make. CB> Most of the C library is _not_ reentrant. About the only safe ones you CB> could use are simple ones, such as abs(), ctype.h, and so on. Forget CB> about I/O or floating point, most of the stdlib.h, most of string.h, and CB> most of the library, actually. Basically, forget about doing any CB> standard C library calls. Oops, a very large part of my program(maybe about halfish) is called from the ISR, absolutly tons of library calls, floating point math, the works. Most of it has been working alright though. CB> I don't know about TC. Dump the assembly and find out. Good idea. CB> You don't call the interrupt function and wait for an interrupt. You CB> chain to it so it's called automatically when an interrupt is done What I meant was wait in one interrupt's function for a different one to happen which has it's own handler which changes some variables which the original one can check to see if the other interrupt has occured. More specifically, wait in the 0x1c timer function for a UART's interrupt. ... No matter how you vote, a government still gets elected. --- Maximus 3.01 * Origin: The Ultimate (3:771/340) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2F00016 Date: 02/10/98 From: VICTOR KEMP Time: 04:04pm \/To: JASEN BETTS (Read 1 times) Subj: qsort-ing a struct NOTE: DCTEdit v0.04 [11] VK> Hi, how do you write the comparison routine to VK> qsort a struct in order VK> of one of it's fields? Slight mistake there, what I meant to say was, 'qsort an array of structs in order of one of the fields'. JB> for integers: JB> int foo_comp( struct foo *a ,struct foo *b ) JB> { JB> return a->fileld-b->field ; JB> } I don't really have any idea what I'm doing but that doesn't appear to work. Probably because it's actually in an array, is foo the name of a struct or the name of a struct type? The error message it gives is: cannot convert 'int (*)(structurename *, structurename *)' to 'int (*)(const void *, const void *)' I'll have to try and figure out exactly what it wants and what to use, is it true that the two parameters are just void pointers to the elements to be compared? Can it not convert a void pointer to a typed one or vise versa? ... The trouble with living sacrifices is that they crawl off the altar. --- Maximus 3.01 * Origin: The Ultimate (3:771/340) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2F00017 Date: 02/11/98 From: BRIAN LUNERGAN Time: 12:50am \/To: ALL (Read 1 times) Subj: Rookie seeks help with a project... * Crossposted in C_PLUSPLUS * Crossposted in C_ECHO Hello All! There's an old expression attributed to BP about expecting and getting the best out the scouts. "When in doubt, hand the kid the end with the jam on ." I have a sysop friend who has done just that to your rookie C++ author. The project is simple. Read a large text file into memory (his files.bbs file) and then rewrite the file, checking each line for certain unwanted text, keeping those lines that pass the "filter", and discarding those that don't. He has one version he did in Pascal, but it has a hard-coded limit of 800 lines. Part of my assignment is to lift that lines restriction so that he can deal with much larger files. I think I have the mechanics of reading in the file worked out and then writing it back to the same file (although I wouldn't mind learning from a few code snippets how others have dealt with this problem); however, I'm not sure how to handle the line by line checking before writing it back to the file. Any help and ideas would be greatly appreciated. "There's no limit to what you can if you don't care who gets the credit..." Brian Lunergan Nepean, ON Canada E-mail: blunergan@cyberus.ca / Fidonet: 1:163/335.44 Member: HTML Writers Guild MS Site Builders Network -- Level 2 ... Don't bother me now, I'm digging up my 'ROOTS'! --- UNREG UNREG * Origin: The Crystal Cave..., Nepean, Ontario, Canada (1:163/335.44) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2F00018 Date: 02/11/98 From: SUNIR SHAH Time: 01:11am \/To: ALL (Read 1 times) Subj: Integral type string size Hey, I'm still alive. Midterms, eh. I'm writing a C++ (that's not really important since I could cin>>(long)foo or something and I don't want to do that so I'm reading in a string instead to be robust) assignment and it came to me that how do I know how many characters wide would a long be? Or an int? I mean if I wanted to display it or read it in. Here's what I came up with... Looks like it works fine: /* This fairly strange calculation determines the number of characters ** required to express a integral type in decimal. It works because ** it takes at LEAST three binary places to shift a decimal number by a ** a place (3 < log2(10)). And you have to round up (+1), plus deal ** with the NUL (+1). ANSI portable. By Sunir Shah ** ** t is the type. */ #include #define INTEGRALSTRINGSIZE(t) ((sizeof(t) * CHAR_BIT)/3 + 2) SS --- Maximus 3.01 * Origin: BitByters BBS, Rockland ON, Can. (613)446-7773 v34, (1:163/215) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2F00019 Date: 02/11/98 From: BOB STOUT Time: 04:05am \/To: JASEN BETTS (Read 1 times) Subj: Memory exchange On , Jasen Betts (3:640/350@fidonet) wrote: > for small areas (like ints) you can do this: > a^=b^=a^=b; > but don't, it confuses people :^) Jasen... Since order of evaluation isn't guaranteed in C, this is bogus. You must instead use: a ^= b; b ^= a; a ^= b; The semicolons are the required sequence points missing from your approach. IOW, it may or may not work, depending on your particular compiler. --- QM v1.00 * Origin: MicroFirm : Down to the C in chips (1:106/2000.6) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2F00020 Date: 02/10/98 From: NEIL HELLER Time: 08:14pm \/To: ALL (Read 1 times) Subj: BOOLEANS Given the function: BOOL invalid_crc(char * pcnd, int length) { return(calculate_crc(pcnd, length) != 0)); } where calculate_crc() is a function which returns an int and BOOL is defined as a system "16-bit Boolean value" (no definition given of "Boolean" that I could find). Would it be proper in this instance to drop the " != 0"? Can boolean have all the values of an int (with only 0 and everything else counting)? * KWQ/2 1.2i * --- FLAME v1.1 * Origin: Port Chicago's Loading Dock - 510-676-5359 (1:161/204) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2F00021 Date: 02/09/98 From: DAMIAN WALKER Time: 04:33pm \/To: AHMAD AL-DOUSARY (Read 1 times) Subj: Memory exchange Hello Ahmad, > I was wondering if it was possible to exchange two areas of memory > without the use of an auxiliary storage in C.. Yes, using exclusive OR. To swap two single integers, you can use the following: x = x ^ y; /* or x ^= y; */ y = y ^ x; /* or y ^= x; */ x = x ^ y; /* or x ^= y; */ So the following function provides you with a swap facility for two blocks of memory: void swap_memory(char *a, char *b, int bytes) { while(bytes--) { *a ^= *b; *b ^= *a; *a ^= *b; a++; b++; } } This code is far from perfect, but it gives you the idea of how this would be done. > BTW this is the C echo isn't it?... (At my BBS it is called OS2 & DOS > echo) That's right, its tag is "C_ECHO". -- Damian Walker --- GEcho 1.11+ * Origin: Centurion - http://www.bsnet.co.uk/net2502/centurion/ (2:2502/666)