/ | \ -------------------------------------- --- GEcho 1.00 * Origin: Home by the C (Auke.Reitsma@net.hcc.nl) (2:281/400.20) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3F00002 Date: 03/08/98 From: AUKE REITSMA Time: 10:27pm \/To: BERNHARD KUEMEL (Read 2 times) Subj: interrupt function Hi Bernhard, On 06 Mar 98, 12:17, you wrote to Victor Kemp ... BK> The intel 80x86 architecture has a different structure (which I BK> am not so familiar with). It uses only 1 interrupt line at the BK> processor and a 1 bit interrupt mask (which can be manipulated BK> with STI and CLI, AFAIK). Thus it also has only 1 priority level BK> for interrupts, IMHO. Several IRQ lines are mapped to this 1 IRQ BK> line and there is an interrupt byte which selects an adress from BK> the interrupt jump table which has 256 entries. This is only partially correct. The 80x86 architecture interfaces up to 15 interrupt lines via Priority Interrupt Controller (PIC) to the processor. Only the interrupt with the highest priority is passed on. There is some more nitty gritty but imho that all is way off topic ... Greetings from _____ /_|__| Auke Reitsma, Delft, The Netherlands. / | \ -------------------------------------- --- GEcho 1.00 * Origin: Home by the C (Auke.Reitsma@net.hcc.nl) (2:281/400.20) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3F00003 Date: 03/09/98 From: ROGER SCUDDER Time: 02:34am \/To: ALL (Read 2 times) Subj: Type detection Hello All. If I pass a pointer to struct to a function and that struct contains a member that is a void pointer and could be pointing to any data type, is there a way to have the function determine the type that the void pointer is pointing to? Pheeeew.... That was a mouthful :-) I hope that's not too hard to follow. -Roger ... An Elephant. A mouse built to government specs --- 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: F3F00004 Date: 03/09/98 From: ROGER SCUDDER Time: 02:50am \/To: TOM TORFS (Read 2 times) Subj: Question.... Hello Tom. 08 Mar 98 10:37, Tom Torfs wrote to Roel Moustie: RM>> what i want to say is that a sentence can be more then once in the RM>> file and i want them all sorted by sentence TT> You want to alphabetically sort them then ? Take a look at this... Or he could do what I would do and filter the file with sed and sort. It's like how every once and a while someone will ask how to make a program that produces output like all the directories and sub- directories on the drive. I tell them to type dir /ad /b /s \ . I think many people are not aware of what is sitting right under their noses and going along with their thinking that they must write a program to achieve what is basic to just about any computer system may really not help them. IOW I'd rather be a little off topic and really help someone than to feel that the solution I provide must be a C program just to stay on topic. Now, if I offer such a solution and the person comes back with "Yes, but I really want to know how to do it with the C language", then I know that the person is not unwittingly about to inflict unnecessary pain on themselves. Well, at any rate, the program you wrote is very nice. :-) -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: F3F00005 Date: 03/10/98 From: BOB STOUT Time: 08:37am \/To: JASEN BETTS (Read 2 times) Subj: What is Snippets? On , Jasen Betts (3:640/350@fidonet) wrote: > I've only got an old version here. > Usage: FRACTION decimal_fraction > returns: decimal_fraction = integer / integer > Is that new version at all like the old one? mine is completely > different. Jasen... Like yours, the new version uses continued fractions. Unlike yours, it is not recursive. Thad also made his PD, a requirement for SNIPPETS. ----[ Fraction.C ]---- /* +++Date last modified: 05-Jul-1997 */ /* ** FRACTION.C - Compute continued fraction series ** ** cfrac() donated to the public domain by the author, Thad Smith ** original Fraction.C, public domain by Bob Stout, modified to use cfrac() */ #include #include #define MAX_LENGTH 100 long double cfrac(long double x, long double *p, long double *q, int bits) { double v; /* integer in series */ long double del; /* x - v */ long double z; /* approximated value from truncated series */ long double t; /* temp */ long double p0 = 0.0, q0 = 0.0; /* last p, q */ long double imax; /* max for p, q */ static long double cf[MAX_LENGTH]; /* continued fraction integers */ int i, j, ntimes = MAX_LENGTH;; if (x < 0) x = -x; imax = floor(pow(2.0, bits)) - 1.0; for (i = 0; i < ntimes; i++) { v = floor((double)x); cf[i] = v; z = cf[i]; *p = z; *q = 1; for (j = i; j--; ) { z = cf[j] + 1.0/z; t = *p; *p = cf[j] * (*p) + (*q); *q = t; } del = x-v; if (del < DBL_EPSILON) break; if ((*p > imax) || (*q > imax)) { *p = p0; *q = q0; break; } else { p0 = *p; q0 = *q; } x = 1.0 / del; } return (*p)/(*q); } #ifdef TEST #include #include main (int argc, char *argv[]) { long double x; /* value to be approximated */ long double r,p,q; /* approx ratio r = p/q */ int bits; /* bits of precision */ if (argc < 2 || argc > 3) { puts ("Use: FRACTION value [precision]"); puts ("where value = floating point value to generate " "continued fraction"); puts (" precision (optional) = bits in " "numerator/denominator"); return 1; } sscanf (argv[1], "%Lf", &x); if (argc == 3) bits = atoi(argv[2]); else bits = 32; cfrac(x, &p, &q, bits); printf("\n[%.20Lf]\n%.0Lf/%.0Lf = %lXh/%lXh = %.20Lf\n", x, p, q, (long)p, (long)q, r = p/q); printf("Error = %.10Lg, (%.10Lf%%)\n", r - x, 100. * (r - x) / x); return EXIT_SUCCESS; } #endif /* TEST */ ----[ finis ]---- --- QM v1.00 * Origin: MicroFirm : Down to the C in chips (1:106/2000.6) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3F00006 Date: 03/01/98 From: MICHAEL STAPLETON Time: 7:17Eam \/To: DONALD BOWERS (Read 2 times) Subj: Re: 'C' & 'C++' -=> On 20 Feb 98 16:52:00 you wrote to me <=- Hello Donald, DB> Is there an easy way to compile C code on Microsoft Visual C++ DB> 4.0? I've got a bunch of C code, and MSVC keeps giving me a DB> bunch of bunk about obsolete keywords & stuff. Can't it see DB> it's C code and not C++??? Sorry, I can't really help you, Donald. I don't use any Microsoft software - I'm an Amiga-only person. :) However, your compiler should have commandline or IDE switches to tell it to compile in ANSI/ISO C mode. Michael Stapleton of Graphic Bits. * AmyBW v2.10 * ... This tagline is encrypted --- AdeptXBBS v1.11z (FREEWare/2) * Origin: Mach One BBS (3:713/615) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3F00007 Date: 03/01/98 From: MICHAEL STAPLETON Time: 6:26Eam \/To: ANTHONY TIBBS (Read 2 times) Subj: Re: i got another simple question -=> On 20 Feb 98 16:44:12 you wrote to me <=- Hi Anthony, PH>> take either no arguments at all, or an int and a pointer to PH>> array of pointers to char, eg.: MS> Almost, Peter, but you used one too many levels of indirection. MS> char *argv[] is an array of pointers to char, char **argv is a MS> pointer to a pointer to char. These two are equivalent here because MS> arrays are always converted to pointers when used as parameters. AT> Peter? Hm, has my name changed recently? No, my comment above was to Peter H. AT> Actually, "int main (int argc, char **argv)" is considered AT> legal, so I didn't use "too many levels" of indirection. Both char **argv and char *argv[] have two levels of indirection, but Peter used three levels of indirection in his verbal description: "pointer to array of pointers". PH>> int main(int argc, char *argv[]) PH>> { PH>> return 0; /* And you must remember to PH>> actually return an int. */ PH>> } AT>> or int main (int argc, char **argv, char **envp) MS> This may be a common extension, but it is not Standard C, MS> TTBOMK. I guess it could work on my system, but I'm quite happy MS> with the functions provided by the Amiga API for accessing MS> environment variables. AT> No, it isn't standard, as Bob pointed out. I'd never use it AT> either, but it is existent. So is the Amiga convention of using 0==argc to signify that the program was started via Workbench, rather than a command shell. However, this is by no means standard and documenting all the non-standard variations of C is beyond the scope of this echo. :) Michael Stapleton of Graphic Bits. * AmyBW v2.10 * ... This tagline is encrypted --- AdeptXBBS v1.11z (FREEWare/2) * Origin: Mach One BBS (3:713/615) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3F00008 Date: 03/07/98 From: MICHAEL STAPLETON Time: 1:35Eam \/To: JASEN BETTS (Read 2 times) Subj: Re: Pritty Lites... -=> On 17 Feb 98 16:29:00 you wrote to me <=- Hi Jasen, MS> I already have a Unix-like Tar program (binary only), but I MS> can't use it, since it doesn't store Amiga Filenotes - a comment MS> (upto 80 bytes) that can be attached to any file or directory. MS> So I had to write my own program. I don't see how the Filenotes MS> feature could be of any use to PC users. :) JB> I could use that... there's a repalcement CLI shell for (ms)dos JB> called 4DOS which has a similar featiure (called Descriptions, JB> which are strings upto 511 characters). A fair point (I'd forgotten about 4DOS Descriptions). However, since my TAR program uses native Amiga API calls to do all the directory handling it would require rewriting from the ground up to port it to the PC world. Besides, in this directory-intensive application I'd lose a lot of speed if I didn't use the native directory calls. Michael Stapleton of Graphic Bits. * AmyBW v2.10 * ... This tagline is encrypted --- AdeptXBBS v1.11z (FREEWare/2) * Origin: Mach One BBS (3:713/615) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3F00009 Date: 03/02/98 From: MICHAEL STAPLETON Time: 2:49Eam \/To: FRANK MASINGILL (Read 2 times) Subj: Re: Calendar [04/08] -=> On 19 Feb 98 07:34:16 you wrote to me <=- Hi Frank, MS> Oops! It should be char month[][12]. Just blame it on dyslexia. :) MS> Thanks for pointing this out. FM> Believe me when I say that it is a distinct honor when I find FM> myself to have corrected, in total ignorance, the mistake of so FM> venerable a programmer. Why, thankyou! I don't normally get called venerable by anyone, let alone someone who's twice my age, but I'll take it as a compliment. :) FM> If I knew what YOU do (grin) I could move on to some of my other FM> hobby interests!! I'm sure what you made was a mere typo and my FM> correction was a pure hunch and nothing much else. My error was reversal at the brain level, not at the finger level. :) The first dimension of an initialised array is free, because the compiler can count the number of entries, but all the other dimensions have to be specified. FM> I'm now very foolishly playing around with a C++Builder compiler FM> I bought with a teaching book. Have fun. :) Michael Stapleton of Graphic Bits. * AmyBW v2.10 * ... This is your brain. This is your brain on C++. Any questions? --- AdeptXBBS v1.11z (FREEWare/2) * Origin: Mach One BBS (3:713/615)