--------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: E5P00025 Date: 05/16/97 From: STEVE DYSON Time: 02:39pm \/To: JERRY COFFIN (Read 3 times) Subj: Re: Want to learn to program -=> Quoting Jerry Coffin to JAKKI SOARES <=- JC> One of the few things you can accurately predict in the computer world JC> is disagreement. I don't agree with that statement. :-) --- Blue Wave v2.12 * Origin: From The Crystal Tower : London (0181-4478244) (2:254/220) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: E5P00026 Date: 05/16/97 From: QUINTIN OLIVER Time: 02:10pm \/To: ALL (Read 3 times) Subj: COM 1 & 2 Hi All, I wonder if anybody can help me, I'm looking for a program that can route information recieved from COM1 to COM2 and visa virsa, I've tried many companys but I'm just NOT getting the help I wan't :-(( Pleeeeease help, Quintin. --- F.I.P.S./32 v0.95 Win95/NT * Origin: The Field BBS - I wonder if they have sheep? (2:250/121.9) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: E5P00027 Date: 05/16/97 From: PAUL DRUGGITT Time: 10:57pm \/To: ALL (Read 3 times) Subj: passing structures to functions Can anyone tell me how to pass structures of different sizes to a function ? I know how to pass a structure of a known size, e.g. ^^^^^^^^^^^^^^^ #include etc... etc... struct RECORD { int type; char desc[26]; } DATA; struct BIGGER_RECORD { int type; char desc[26]; char address_1[40]; char address_2[40]; int record_number; } BIGGER_DATA; void display_data(struct RECORD *rec_name); ^^^^^^^^^^^^^ int main(void) { display_data(&DATA); return(0); } void (display_data(struct RECORD *rec_name) { ^^^^^^^^^^^^^ if(rec_name->type <= 100) printf("type = %d", rec_name->type); else printf("type is more than 100"); printf("\ndesc = %s", rec_name->desc); } Now, is it possible to write a single function that will accept ANY structure as a parameter, stating which member to compare? eg. int main(void) { display_data(&DATA, DATA.type); display_data(&BIGGER_DATA, BIGGER_DATA.type); return(0); } I have tried to pass a void pointer to my function, but cannot access individual members of the structure to perform comparisons. eg. void(void *rec_name, unsigned member_to_test); Any help would as usual be much appreciated. Regards, Paul Druggitt. FIDONET NETMAIL Address 2:250/121 Internet E-Mail Address paul.druggitt@fieldbbs.overflow.com --- * Origin: The Field BBS * 01706 868997 * 24 Hours V34+ (2:250/121) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: E5P00029 Date: 05/18/97 From: KURT KUZBA Time: 10:30pm \/To: JAVIER KOHEN (Read 3 times) Subj: DOS commands JK> KK> You may use the ANSI standard system() function. JK> KK> system(command_string); JK> Borland says it's not ANSI. :/ jk>.... What version are you using?! In my 3.1 manual, there are little dots in the DOS, UNIX, and ANSI boxes in the compatibility chart. Maybe your book is printed upside down! :) > ] What do you mean, "There is more to life than computers."?.. --- * Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: E5P00030 Date: 05/18/97 From: KURT KUZBA Time: 10:31pm \/To: JIM ROBIN (Read 3 times) Subj: Throw of dice JR> generate numbers between a lower bound value and an upper JR> bound value - in the case of the dice example 1 - 6. jr>.... Not exactly a C++ question, really, but I suppose one could construct a dice class easily enough. :) Test it out and see how it works for you. //_|_|_| DIECLASS.CPP // //_|_|_| A simple dice class for C++ programs. // //_|_|_| No warrantee or guarantee is given or implied. // //_|_|_| PUBLIC DOMAIN by Kurt Kuzba. (5/18/1997) // #include #include #include // begin: Dice class definition and function code // class Dice { public: Dice(int dice, int sides) { srand((unsigned)time(NULL)); number_dice = dice; number_sides = sides; dice_values = new int[dice]; } ~Dice(void) { delete []dice_values; } int Roll(void) { int die, total = 0; for(die = 0; die < number_dice; die++) total += (*(dice_values + die) = rnd(number_sides) + 1); return total; } const int *Get_dice(void) { return (const int*)dice_values; } private: int rnd(int max) { return (int)((((long)rand() * (long)max) - 1L) / (long)RAND_MAX); } int *dice_values, number_dice, number_sides; }; // end: Dice class definition and function code // // begin: Test program for Dice class // int main(void) { Dice four_by_nine(4, 9); const int *dice; int rolls; cout << "\n\nOur four dice each have nine sides.\n"; for(rolls = 0; rolls < 5; rolls++) { cout << "A roll of the dice gives us " << four_by_nine.Roll(); dice = four_by_nine.Get_dice(); cout << "\nwith the four dice values being:\n" << *(dice + 0) << ", " << *(dice + 1) << ", " << *(dice + 2) << ", " << *(dice + 3) << '\n'; } cout << "This has been almost nearly random. :)\n" << flush; return 0; } // end: Test program for Dice class functions // //_|_|_| End DIECLASS.CPP // > ] People with glass heads shouldn't.. Ummm.. I forgot......... --- * Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: E5P00031 Date: 05/18/97 From: KURT KUZBA Time: 10:31pm \/To: BOB STOUT (Read 3 times) Subj: Throw of dice BS> Look up ROLLDICE.C in SNIPPETS. Although it's in C, I BS> also have a C++ implementation saved here somewhere, BS> although I can't find it right this minute. bs>... Thanks for the support. :) I just posted a C++ version. The one in SNIPPETS, by the way, may not give the full range of numbers as it should. You really need to go one above your maximum and then subtract one from the result before the division to ensure the full range of integer values, 0-max.9999. Otherwise, you get a proportionally uneven distribution on the highest allowable value in your random routine. In short, though it did look good, I actually screwed up again. *(- sigh -)* Much better now, though... > ] This Universe is 3-D captioned for the Magic Eye impaired... --- * Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: E5P00032 Date: 05/18/97 From: CLIFF RHODES Time: 09:51pm \/To: PAUL DRUGGITT (Read 3 times) Subj: passing structures to fu --> Paul Druggitt wrote to All <-- PD> Can anyone tell me how to pass structures of different sizes to a PD> function ? PD> PD> I know how to pass a structure of a known size, e.g. PD> ^^^^^^^^^^^^^^^ PD> Now, is it possible to write a single function that will accept PD>ANY structure as a parameter, stating which member to compare? PD> PD> eg. PD> PD> int main(void) PD> { PD> PD> display_data(&DATA, DATA.type); PD> display_data(&BIGGER_DATA, BIGGER_DATA.type); PD> PD> return(0); PD> } PD> PD> PD> I have tried to pass a void pointer to my function, but cannot PD>access individual members of the structure to perform comparisons. If you can do what you want in the function with just one structure member, why do you need to pass the entire struct? Just pass the member. Or am I missing something in your question? Cliff Rhodes cliff.rhodes@juge.com X CMPQwk 1.42 1692 X"Man's speech is like his life." - Plato --- Maximus/2 3.01 * Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: E5P00033 Date: 05/18/97 From: JERRY JANKURA Time: 10:29pm \/To: LOUIS RIZZUTO (Read 3 times) Subj: Low level optimizatio 1/2 LR>Is it plausible to write such RT apps in C++ - and still meet real LR>time criteria? I am not sure. Perhaps some else here can comment LR>on this. Yes, it is definitely possible and reasonable to write RT applications in C++. That way, you can have the benefits of function overloading, type-safe parameter passing, default parameters, etc. However, you may decide that a given application is not suitable for implementation as an object oriented system because of some of the real time requirements of that application. Remember, you don't have to use object oriented programming technques or classes to obtain many of the benefits of C++ -- Jerry --- * OLXWin 1.00b * * Eval Day 8 * Ben, Dover, and C. Howitt Fields - Attorneys at L --- InterEcho 1.19 * Origin: PC-Ohio PCBoard * Cleveland, OH * 216-381-3320 (1:157/200) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: E5P00034 Date: 05/18/97 From: JANI SAKSA Time: 09:44pm \/To: QUINTIN OLIVER (Read 3 times) Subj: Re: DJGPP -=> Propably Quintin Oliver wrote to ALL <=- Hello Quintin! QO> Hi All, QO> QO> QO> Does anyone know where I can find DJGPP? www.delorie.com // // Sir Robin (jsaksa79@hotmail.com) // http://www.cybercity.hko.net/Tokyo/jsaksa/index.html // DooM-page, programming stuff, music page // ... He's got a magnet!!! Everybody BACKUP!!!!!!!! --- BBBS/2 v3.33 How-C * Origin: Cat-Box - 02-4841086 (2:222/120) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: E5P00035 Date: 05/18/97 From: JANI SAKSA Time: 09:44pm \/To: NIKLAS NYLUND (Read 3 times) Subj: Re: graphics! -=> Propably Niklas Nylund wrote to All <=- Hello Niklas! NN> Where can i find a good graphics library for borland c++, with full NN> source code, on how to load pictures in vga and svga!?? Could anybody NN> tell me a good ftp/web site or any other place? Propably from: ftp://x2ftp.oulu.fi // // Sir Robin (jsaksa79@hotmail.com) // http://www.cybercity.hko.net/Tokyo/jsaksa/index.html // DooM-page, programming stuff, music page // ... "En piittaa, piittaa, vaan litkin aperiittaa!" --- BBBS/2 v3.33 How-C * Origin: Cat-Box - 02-4841086 (2:222/120)