--------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F3S00007 Date: 03/20/98 From: TIM HUTZLER Time: 06:14pm \/To: KURT KUZBA (Read 3 times) Subj: Re: Sort Algorithm TH> Anyone who chooses to use a bubble sort has got air TH> between their ears. [grin] KK>If you are never REsorting your data, and only adding a single new KK>element now and then, the bubble sort makes sense. What makes 'sense' depends on what one knows about the alternatives. The algorithm for a bubble sort is simple to understand and implement. For very small arrays (less than, say, 30 elements) a bubble sort is fine. However, for a large number of elements, even a sorted list begins to fall down. That's because even a sorted list is O(n), and an unsorted list is O(N^2/2)! OTOH, a heap is only slightly more complex, but its effiency is O(log2N), which means that it will be 10,000 times faster than a bubble sort sorting only 100 elements! It is almost a million times faster sorting 1,000 elements! I wrote a heap sort class, and I use it a lot for priority trees and stuff like that. KK>A modification of it, which compares the item to be inserted to KK>the middle element is even quicker, of course, but for a limited KK>list, such as a top ten players list in a game environment, the KK>bubble sort is perfectly adequate. Yes, I would agree. ___ Blue Wave/QWK v2.12 --- Maximus/2 3.01 * Origin: Madman BBS * Chico, California * 530-893-8079 * (1:119/88) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F3S00008 Date: 03/20/98 From: TIM HUTZLER Time: 06:35pm \/To: PHIL OHL (Read 3 times) Subj: Re: I'm an idiot -=>Quoting Phil Ohl to All <=- PO>I am fairly new at C++ and i have encountered a pretty major problem PO>(I've had several). Anyway, I know that you cant use 'cin' if there PO>is going to be spaces withing your input and I have learned to use PO>'getline' in its place. However 'getline' doesn't work all the time PO>either especially when i do something like: PO>char name[20]; PO>cout<<"Enter name: "; PO>getline(name, cin); PO>It just wont work. How would I remedy this problem without limiting PO>the user to just their first or last name. Use the following code: char name[15]; gets(name,15); //"name" is the string, "15" is the maximum number of chars PO>I know its a very novice problem but I just don't know. The I guess you can ask... We're friendly, damnit! [grin] ___ Blue Wave/QWK v2.12 --- Maximus/2 3.01 * Origin: Madman BBS * Chico, California * 530-893-8079 * (1:119/88) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F3S00009 Date: 03/20/98 From: TIM HUTZLER Time: 06:38pm \/To: MARK HOOVER (Read 3 times) Subj: Re: Need More Memory -=>Quoting Mark Hoover to All <=- MH>Hey folks.... MH>Need a little help here.... MH>I'm trying to read a rather large file into memory 200k+ and I MH>keep encountering out of memory errors with the "new" keyword even MH>with the Huge memory model. The "real" memory model limits *any* arrays to 65536 bytes. You will have to use 32-bit addressing. Why not read sections at a time? ___ Blue Wave/QWK v2.12 --- Maximus/2 3.01 * Origin: Madman BBS * Chico, California * 530-893-8079 * (1:119/88) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F3S00010 Date: 03/20/98 From: TIM HUTZLER Time: 07:02pm \/To: TIMO FINNIL (Read 3 times) Subj: Re: Sorting linked list TF>Help me please, i got a big problem %-) TF>How do i (quick)sort linked lists? Collect the pointers into an array. Sort the pointers using whatever key you wish to sort by. Then build a new linked list. ___ Blue Wave/QWK v2.12 --- Maximus/2 3.01 * Origin: Madman BBS * Chico, California * 530-893-8079 * (1:119/88) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F3S00011 Date: 03/20/98 From: SEBASTIAN NOZZI Time: 07:41pm \/To: ALL (Read 3 times) Subj: Data Base, how to program it? int Buenas("All"){ I've been planing to progam a simple database engine in C++, nothing serious, just that I can use it whenever I have to mantain simple data ordered such as strings, but I would also use it for multiple-data lines. The problem is, I don't know what the best approach would be. The only thing I know is that programming it in an OOP approach wouldn't be a bad idea, but I'm stuck. Any ideas, any suggestions? Hasta_luego(); return( Sebastian_Nozzi); } --- Terminate 4.00/Pro * Origin: The C++ Programming Lab. (4:900/214.81) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F3S00012 Date: 03/23/98 From: RIMU ATKINSON Time: 1:03am \/To: PHIL OHL (Read 3 times) Subj: Re: I'm an idiot use the gets() function to get a line of text from stdin. eg: char name[40]; gets(name); --- CNet/3 * Origin: Phone The Bridge Baud 64-7-8430086 AMIGA! (3:774/640) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F3S00013 Date: 03/22/98 From: MICHAEL MCGAVIN Time: 04:24pm \/To: ALL (Read 3 times) Subj: passing by reference Hi All, I'm largely self taught in C/C++ but I've just started doing a more formal course in it. Anyway, we just started covering copy constructors in classes which is something I haven't hit before. It's not the idea of what it does that confuses me, it's the way the parameter is passed to it. Whenever I want to pass something by reference I do it manually (as follows): void afunction(int *var1) { *var1=546; } void main() { int k; afunction(&k); } - this works out logically as far as I can tell. As in the declaration says that '*var1' is an integer, and so 'var1' by itself is a pointer to the integer. Then I just make sure that when I call the function I pass a pointer to the integer instead of the integer itself. So anyway, I suddenly found out that the way to declare a copy constructor is (not bothering with the specifics of any class so I'll just write an ordinary function): void afunction(int &var1) { var1=546; } void main() { int k; afunction(k); } ie. An integer variable can just be passed to it ordinarily. This is really confusing me. :-) I hate trying to work out where pointers are going and stuff but by my logic so far, '&var1' would be an integer and so 'var1' would be a junk value pointed to by whatever was currently in the integer. Is it just me who's having a hell of a time thinking this through or is this some sort of exception in the design of the language whereby a '&' character can be used to get the compiler to automagically work out all the pointer stuff? :-] Thanks for any help. Mike. email: zog@sans.vuw.ac.nz --- GoldEd 2.50 UNREG * Origin: DARK SKIES Astronomy -- Wgtn, NZ. +64-4-235-6887 (3:771/1560.201) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F3T00000 Date: 03/23/98 From: DARIN MCBRIDE Time: 07:31am \/To: MICHAEL MCGAVIN (Read 3 times) Subj: passing by reference MM> Whenever I want to pass something by reference I do it MM> manually (as follows): MM> void afunction(int *var1) MM> { MM> *var1=546; MM> } MM> void main() MM> { MM> int k; MM> afunction(&k); MM> } This isn't passing by reference, per se. It's passing a pointer to an object. The difference is, as you say, "manual." Reference passing in every language is an automatic thing handled by the compiler. For example, many people coming from a pascal background would recognize: procedure foo(var integer: by_ref; integer: by_val; integer^: by_ptr); A special keyword (var) allows you to pass the item by reference where the compiler will handle the "link" between the by_ref variable in the procedure and the parameter that was originally passed in. C++'s special keyword is the &. :-) void foo(int& by_ref, int by_val, int* by_ptr); Note that by_ptr is _still_ a method of passing _by value_. You are passing the _value_ of the pointer itself, which, indirectly, can be used (with the * [dereference] operator) as a reference. MM> - this works out logically as far as I can tell. As in MM> the declaration says that '*var1' is an integer, and so MM> 'var1' by itself is a pointer to the integer. Then I Right - by_ptr would be, by itself a "int *" or a pointer to int. by_val would be a "int" or just an int. And by_val would be "int&" or _reference_ to int. MM> ie. An integer variable can just be passed to it MM> ordinarily. This is really confusing me. :-) I hate MM> trying to work out where pointers are going and stuff MM> but by my logic so far, '&var1' would be an integer and Actually, the interesting thing is how &var1 would work. #include void foo(int& k) { cout << "in foo, &k = " << (void*)&k << endl; } int main() { int main_k; cout << "in main, &main_k = " << (void*)&main_k << endl; foo(main_k); return 0; } The output would show something very interesting. &k will be identical to &main_k! They both automagically have the same pointer. Thinking of k as just "an int", you can see how k can have its address taken... but as a reference, its address will be the same as the object it refers to, in this case, main_k. MM> Is it just me who's having a hell of a time thinking MM> this through or is this some sort of exception in the MM> design of the language whereby a '&' character can be MM> used to get the compiler to automagically work out all MM> the pointer stuff? :-] In variable declaration, & makes the variable a _reference_ to a type. This is not completely unlike the miriad of meanings some of the other symbols have... such as static, * (multiply, dereference, declare a pointer), ... Hope this helps, --- * Origin: Tanktalus' Tower BBS (1:250/102) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F3T00001 Date: 03/18/98 From: JARED MORGAN Time: 12:51pm \/To: RICHARD HIRNER (Read 3 times) Subj: Changing Win 3.11 *** Quoting Richard Hirner to Jared Morgan dated 03-15-98 *** > Hello! > > 07 Mar 98 12:42:20: Jared Morgan -> All, "Changing Win 3.11" > > JM> Is there a way to use Turbo C++ to "modify" Win 3.11 programs > JM> to work in win 95? > > I can't imagine. But why to do so? Win95 runs (almost) all > Win 3.11 programs correctly. > > Richard > *** I have PC tools for windows central point desktop 2.0 I have several programs I would like to use in win95 such as multi-desktops etc. I learned it "WAS" possable to do so, I also would like to know how to increase the colors (when I raise the resoultion then add a new icon the color is off and/or doesn't show) maybe you could help. --- FMail/386 1.02 * Origin: KastlerocK + Jeannette, PA + 412.527.3749 (1:129/230) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F3T00002 Date: 03/22/98 From: CAREY BLOODWORTH Time: 09:21pm \/To: FREDERIC LHOEST (Read 3 times) Subj: RE: CURSES FL> FL>> I'm searching CURSES.H and NCURSE.H for DOS ! FL> CB> There are various CURSES ports to DOS. FL>Pretty cooool ! :) FL> CB> For regular 16 bit curses, there are a couple in the C User's group FL>So ... do you have an Internet address for me ? :) No. I have no idea. However, I know a board that has the cd, so I grabbed them, and they aren't really worth trying. One is only pre-compiled libraries, and the other is an early version of a newer one you can get. The PDCurses is a fairly portable version that has already been ported to a number of platforms. Here is the (I think) main site for it. I got it from the docs, so I don't know if it's still used, etc. site: ftp.gu.edu.au 132.234.1.1 directory: /src/PDCurses -rw-r--r-- 1 root 11 652 Feb 14 03:35 README -rw-r--r-- 1 root 11 129916 Feb 14 03:35 pdcbcc22.zip -rw-r--r-- 1 root 11 97519 Feb 14 03:35 pdcdjg22.zip -rw-r--r-- 1 root 11 116055 Feb 14 03:35 pdcemx22.zip -rw-r--r-- 1 root 11 90133 Feb 14 03:35 pdcicc22.zip -rw-r--r-- 1 root 11 125925 Feb 14 03:35 pdcmsc22.zip -rw-r--r-- 1 root 11 225741 Feb 14 03:35 pdcurs22.zip You can also get it from any place that does the DJGPP v2 compiler. It'll be in one of the few subdirectories. The simtel site (ftp.simtel.net) also has the djgpp version (in the djgpp directory) and the 'plain' pdcurs22 in one of the msdos directories. Probably either 'c' or 'screen utilities' etc. (There is a package called aecurses in the DJGPP v1 directories, but it's older and is copyrighted source. Not really worth using when you can do PD instead.) As for Ncurses..... It turns out there is a GNU ncurses package (available on any gnu ftp site), but I haven't seen it ported to dos. What I saw was the patches to port it to EMX (linux, etc.).... So you'd have to port that yourself, I guess. --- QScan/PCB v1.19b / 01-0162 * Origin: Jackalope Junction 501-785-5381 Ft Smith AR (1:3822/1)