--------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EAM00004 Date: 06/15/97 From: NEIL BURROWS Time: 03:57pm \/To: JERRY COFFIN (Read 3 times) Subj: Binary Search Tree Hi, 07-Jun-97 16:53:40, Jerry Coffin wrote to Neil Burrows Subject: Binary Search Tree NB>> Unless your as thick as me and load in a dictionary file which is NB>> already in alphabetical order! :( JC> This is still fairly easy to handle as a rule. Load the data into JC> memory in an array, then create your binary tree out of the data JC> recursively. This is true, however it is not the most efficient of methods, as you will have two copies of every word in memory at the end. See ya, Neil Burrows Internet: neil@remo.demon.co.uk * Web : ttp://www.remo.demon.co.uk/ : nburrows@cs.strath.ac.uk * FidoNet : 2:259/36.19 --- Terminate 4.00/Pro * Origin: Flight of Fantasy BBS. Glasgow, Scotland, UK. (2:259/36.19) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EAM00005 Date: 06/15/97 From: KEVIN CAMPBELL Time: 09:48pm \/To: PAUL WANKADIA (Read 3 times) Subj: Borland Builder > Is the following tidbit of code correct? > ===== > if (stricmp(demo.size, "huge")) { > for (loop = 0 ; loop < 1275 ; loop++) phone.cost++ > } Looks fine. What is the structure for Demo and Phone, and what is loop defined as (int/char)? Oh, and you've missed a semi-colon right after phont.cost++ Have Fun - Kev Kevin Campbell Sysop of Deimos BBS E-Mail: Sysop@Deimos.unmanned.co.uk --- FMail/386 1.02 * Origin: Mail shipped from Deimos Spaceport (2:259/17) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EAM00006 Date: 06/16/97 From: PAUL ELLIOTT Time: 05:59pm \/To: ALL (Read 3 times) Subj: C++ Problem Hi All, I'm creating a last callers PEX for ProBoard (basicly the same as a standard EXE but uses a communications library with extra bits stuck on) but i'm having big problems with it. Here's the problem. A simple last callers pex is supplied with ProBoard but its in C and not C++. The only way I can get it to compile is by forcing borland to compile C and not C++. If I try to use C++ I get the error: - Borland C++ 4.51 Copyright (c) 1987, 1994 Borland International _lc.c: Error _lc.c 57: Cannot convert 'void *' to 'BINLOG *' in function main(int,char * *) *** 1 errors in Compile *** Here's a copy of line 57: - bl = malloc( lc_num * sizeof(BINLOG)); Could anybody help me get around this problem as a lot of my existing code is in C++ so I can't include it with any programs with this line. If anybody would like the full listing of the _LC.C file write a fidonet ROUTED netmail addressed to Infomail at 2:2502/27 with the subject CPROBLEM and the mail server will send you a copy via routed netmail. You will have to include something in the message body or the request will fail. Hope some people out there will have a bit more success with this problem then I have, i've been working on this for weeks now :( ______ _____ __ __ __ ==========HOME OF THE SYNERGY SYSTEM========== | _ || _ || | || | = Specialising in ProBoard PEX development = | ___|| || | || |_ = Sponsored by AMF Bowling = |__| |__|__||_____||____| ===============Fidonet 2:2502/27============== *** THE READER V4.50 [freeware] --- FMail/Win32 1.22 * Origin: T H E S Y N E R G Y S Y S T E M (2:2502/27) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EAN00000 Date: 06/17/97 From: CAREY BLOODWORTH Time: 09:15pm \/To: VIRGIL GARNESS (Read 3 times) Subj: Passing switches to progr VG>How is it possible to pass switches to bypass a Switch in a program, say VG>like from the dos prompt. I'm trying to make a program that can run on VG>it's own normally with a menu or run in a batch file with switches to VG>bypass the menus. Just check argv & argc in main(). I'd guess that if there are valid arguments passed on the command line, you could bypass the menu and just do what needs to be done. You can either write your own argument processor and use one of the several getopt() functions that are floating around (including in the C Snippets release.) --- QScan/PCB v1.19b / 01-0162 * Origin: Jackalope Junction 501-785-5381 Ft Smith AR (1:3822/1) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EAN00001 Date: 06/18/97 From: EDWARD RUTLEDGE Time: 05:53am \/To: VIRGIL GARNESS (Read 3 times) Subj: Passing switches to progr On 06-13-97 VIRGIL GARNESS wrote to ALL... VG> Hi All, How is it possible to pass switches to bypass a Switch VG> in a program, say like from the dos prompt. I'm trying to VG> make a program that can run on it's own normally with a menu VG> or run in a batch file with switches to bypass the menus. VG> Any help 'preciated VG> Later..... This program does exactly what you want to do. I will include the entire program although you will undoubtedly want to do something totally different. I hope that this helps. Ed /* zztst-x9.cpp Convert Gregorian to Julian Has some improved fail-safe functions. Added the necessary code to be given a date and days hence then return the new date in commercial Gregorian format. (Is able to go past the year boundry.) Needs more fail-safing for the Julian input. (If days > 365 (366 for leap year) then work up the required code to be able to handle the year boundry limits.) Fixed the year boundry limits. Added negative days failsafe code for date plus days delay. Added code to handle negative days delay given two dates. Added century leap year code. On centurys that are evenly devisiable by 400 the leap year has 366 days. On "leap years" that are not evenly divisable by 400 the leap year is to have 365 days. Use pointers to get to month definations (a memory saving technique). Also added code to further expand the century leap year capability. Added the capability of bringing in some of the values from the command line. Changed the error codes returned by the exit() function. */ #include #include #include // Variables used by multiple functions (Common) long year; int month, day, total_days; int days_per_month [ 12 ] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; char* month_1 [ 3 ] [ 12 ] = { { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }, { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }, { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" } }; // Prototype functions long to_julian ( ); //Input Gregorian to Julian long to_julian ( int, int, long ); //Convert to Julian void to_gregorian ( long ); //Convert Julian to Gregorian void to_gregorian ( long, int&, int&, int& ); //Convert to Julian long leap_year ( long, int ); //Adj Feb if leap year X 1000 void leap_year ( long ); //Adj Feb if leap year int in_day ( int ); //Input day int in_month ( ); //Input month int Total_days ( int, int ); //Return day of year void greg_ ( int& , int& ); //Convert Julian to Greg M&D int Days_Between ( long, long ); //Determine days between years int Days_in_year ( long ); //Return days in year (long) long double char_t_float ( char* ); //Convert char to float pt. char character ( char* ); void main ( int argc, char* argv [ ] ) { long temp; int month_, day_, year_; int month_dsp = 0; int days = 0; int xtemp = 0; char direction; long start_; long end_; long tempx [ 10 ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; if ( argc == 1 ) { cout << "\nFrom Gregorian To Julian = 0, " << "\nFrom julian (to Gregorian) = 1," << "\nAdd days of Delay to date = 2," << "\nNumber of days delay Between two dates = 3" << "\nWhat is the desired function? "; direction = getche ( ); cout << '\n'; } else { if ( argc > 9 ) { cout << "To many input parameters\n"; exit ( 100 ); } direction = character ( argv [ 1 ] ); for ( int j = 2; j < argc; j ++ ) { tempx [ j ] = char_t_float ( argv [ j ] ); } } switch ( direction ) { case '0': case 't': case 'T': case 'j': case 'J': if ( argc == 5 ) cout << to_julian ( tempx [ 2 ], tempx [ 3 ], tempx [ 4 ] ) % 100000 << endl; else cout << '\n' << to_julian ( ) % 100000 << endl; break; case '1': case 'f': case 'F': case 'g': case 'G': if ( argc == 4 ) { if ( tempx [ 3 ] > 2 | tempx [ 3 ] < 0 ) { cout << "Wrong month specification " << "(0 = Month, 1 = Mon, 2 = " << " month number )"; exit ( 120 ); } month_dsp = tempx [ 3 ]; temp = tempx [ 2 ]; } else { cout << "How do you want the month " << "displayed? \n" << "(0 = Month, 1 = Mon, 2 = " << "month number) "; cin >> month_dsp; if ( month_dsp > 2 | month_dsp < 0 ) { cout << "Wrong month specification " << "(0 = Month, 1 = Mon, 2 = " << " month number )"; exit ( 121 ); } cout << "\nPlease input the Julian date: "; cin >> temp; } to_gregorian ( temp, month_, day_, year_ ); if ( month_dsp > 1 ) cout << month_1 [ month_dsp ] [ month_ - 1 ] << "/" << day_ << "/" << year_ << endl; else cout << month_1 [ month_dsp ] [ month_ - 1 ] << " " << day_ << ", " << year_ << endl; break; case '2': case 'D': case 'd': case 'A': case 'a': if ( argc >= 6 && argc <= 7 ) { temp = to_julian ( tempx [ 2 ], tempx [ 3 ], tempx [ 4 ] ); days = tempx [ 5 ]; if ( argc == 7 ) { if ( tempx [ 6 ] >= 0 && tempx [ 6 ] <= 2 ) { month_dsp = tempx [ 6 ]; } else { month_dsp = 0; } } else { month_dsp = 0; } } else { cout << '\n'; month_dsp = 0; temp = to_julian ( ); cout << "Input number of days of delay = "; cin >> days; } if ( days < 0 ) { cout << "Error 167:48\n" << "Unable to handle negative days!\n"; exit ( 110 ); } xtemp = Days_in_year ( temp ); if ( ( days + temp % 1000 ) > xtemp ) { year_ = temp / 1000; days += temp % 1000; while ( days >= xtemp ) { days -= xtemp; year_++; xtemp = Days_in_year ( year_ ); } temp = year_; temp *= 1000; temp += days; } else temp += days; to_gregorian ( temp, month_, day_, year_ ); if ( month_dsp > 1 ) cout << month_1 [ month_dsp ] [ month_ - 1 ] << "/" << day_ << "/" << year_ << endl; else cout << month_1 [ month_dsp ] [ month_ - 1 ] << " " << day_ << ", " << year_ << endl; break; case '3': case 'b': case 'B': case 'N': case 'n': if ( argc == 8 ) { start_ = to_julian ( tempx [ 2 ], tempx [ 3 ], tempx [ 4 ] ); end_ = to_julian ( tempx [ 5 ], tempx [ 6 ], tempx [ 7 ] ); } else { cout << "\nStart Date\n"; start_ = to_julian ( ); cout << "End Date\n"; end_ = to_julian ( ); } cout << Days_Between ( start_, end_ ) << " Days.\n"; break; } exit ( argc - 1 ); } long to_julian ( ) { cout << "Enter year: "; cin >> year; leap_year ( year ); month = in_month ( ); day = in_day ( month ); total_days = Total_days ( day, month ); return ( year * 1000 ) + total_days; } long to_julian ( int month, int day, long year ) { long temp; temp = leap_year ( year, 1000 ); total_days = Total_days ( day, month ); return temp + total_days; } void to_gregorian ( long julian ) { int year_greg; int day_greg; int month_greg; year_greg = julian / 1000; day_greg = julian % 1000; leap_year ( year_greg ); greg_ ( month_greg, day_greg ); cout << '\n' << "Gregorian date is : " << month_greg << "/" << day_greg << "/" << year_greg; } void to_gregorian ( long julian, int& month_greg, int& day_greg, int& year_greg ) { year_greg = julian / 1000; day_greg = julian % 1000; leap_year ( year_greg ); greg_ ( month_greg, day_greg ); } long leap_year ( long year, int k ) { leap_year ( year ); return year *= k; } void leap_year ( long year ) { if ( year % 4 == 0 ) days_per_month [ 1 ] = 29; else days_per_month [ 1 ] = 28; if ( year % 100 == 0 && year % 400 != 0 ) days_per_month [ 1 ] = 28; } int in_month ( ) { month = 0; while ( month < 1 | month > 12 ) { cout << "Enter month (1 to 12): "; cin >> month; } return month; } int in_day ( int month ) { day = 0; while ( day < 1 | day > days_per_month [ month - 1 ] ) { cout << "Enter day (1 to " << days_per_month [ month - 1 ] << "): "; cin >> day; } return day; } int Total_days ( int day, int month_ ) { int j; total_days = day; for ( j = 0; j < month_ - 1; j ++ ) total_days += days_per_month [ j ]; return total_days; } void greg_ ( int& monthx, int& daysx ) { monthx = 1; while ( daysx > days_per_month [ monthx - 1 ] ) { daysx -= days_per_month [ monthx -1 ]; monthx ++; } } int Days_Between ( long start, long end ) { int temp1 = 0; int temp2 = 0; int startx; int endx; if ( ( end / 1000 ) > ( start / 1000 ) ) { startx = start / 1000; endx = end / 1000; } else { endx = start / 1000; startx = end / 1000; } for ( int running = startx + 1; running <= endx; running ++ ) temp2 += Days_in_year ( running ); temp1 = ( ( end % 1000 ) - ( start % 1000 ) ); if ( ( end / 1000 ) > ( start / 1000 ) ) return temp1 + temp2; else return temp1 - temp2; } int Days_in_year ( long oops ) { if ( oops > 10000 ) oops /= 1000; if ( ( oops % 4 ) == 0 ) { if ( oops % 100 == 0 && oops % 400 != 0 ) return 365; else return 366; } else return 365; } char character ( char* doit ) { return *doit; } /* Routine to convert "character" numbers into long double decimal values. (In this case used if values are brought through the command line input.) */ long double char_t_float ( char* ps ) { long double build ( long double, int, int& ); // Prototype function long double temp = 0.0; int flag = 0; int nflag = 0; int pflag = 0; while ( *ps ) { switch ( *ps ++ ) { case '0': // Convert 0 temp = build ( temp, 0, flag ); break; case '1': // Convert 1 temp = build ( temp, 1, flag ); break; case '2': // Convert 2 temp = build ( temp, 2, flag ); break; case '3': // Convert 3 temp = build ( temp, 3, flag ); break; case '4': // Convert 4 temp = build ( temp, 4, flag ); break; case '5': // Convert 5 temp = build ( temp, 5, flag ); break; case '6': // Convert 6 temp = build ( temp, 6, flag ); break; case '7': // Convert 7 temp = build ( temp, 7, flag ); break; case '8': // Convert 8 temp = build ( temp, 8, flag ); break; case '9': // Convert 9 temp = build ( temp, 9, flag ); break; case ',': // Ignores commas break; case '.': // Processes a period if ( flag >= 1 ) { cputs ( "\rProgram aborted! " ); cout << "To many decimal points."; exit ( 210 ); } flag = 1; break; case '-': // Processes a negative if ( nflag >= 1 ) { cputs ( "\rProgram aborted! " ); cout << "To many minus signs."; exit ( 211 ); } nflag = 1 ; break; case '+': // Processes a plus sign if ( pflag >= 1 ) { cputs ( "\rProgram aborted! " ); cout << "To many minus signs."; exit ( 212 ); } pflag = 1 ; break; default: // Take care of illegal character cputs ( "\rProgram aborted! " ); cout << "Needs to be neumeric. " << "\n\rNo alphabitic or other " << "characters allowd."; exit ( 213 ); } } if ( nflag == 0 ) // Return value rotine return temp; // Returns value with same sign else return temp * ( -1.0 ); // Returns value with changed sign } /* This function is called by the conversion routine. */ long double build ( long double ret_val, int no, int& flag ) { long double temp; temp = float ( no ); // Convert integer to floating point if ( flag == 0 ) // Determine if left or right of decimal { return ( ret_val * 10.0 ) + temp; // Left of decimal } else { for ( int n = 1; n <= flag; n ++ ) // Right of decimal { temp /= 10.0; } flag ++; return ret_val + temp; // Returns value } } --- * OFFLINE 1.58 --- WILDMAIL!/WC v4.12 * Origin: Star Tech Diamond Bar, CA 909-396-4227 714-257-1175 (1:218/801.0) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EAN00002 Date: 06/18/97 From: JERRY COFFIN Time: 11:59am \/To: NEIL BURROWS (Read 3 times) Subj: Binary Search Tree On (15 Jun 97) Neil Burrows wrote to Jerry Coffin... JC> This is still fairly easy to handle as a rule. Load the data JC> into memory in an array, then create your binary tree out of the JC> data recursively. NB> This is true, however it is not the most efficient of methods, as you NB> will have two copies of every word in memory at the end. Not necessarily. Assuming your nodes contain pointers to the actual data, you can simply point them at the data in the array instead of to individually allocated structs. However, you do have to be a bit careful about deleting objects from the tree if you do this, as you can't simply free() one item in the array without causing problems. You can usually work around this by simply marking items as deleted instead of freeing them, at least if they're in the original array. This usually means using a byte or so for bookeeping. Later, Jerry. ... The Universe is a figment of its own imagination. --- PPoint 1.90 * Origin: Point Pointedly Pointless (1:128/166.5) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EAN00003 Date: 06/18/97 From: JERRY COFFIN Time: 12:02pm \/To: PAUL ELLIOTT (Read 3 times) Subj: C++ Problem On (16 Jun 97) Paul Elliott wrote to All... PE> Error _lc.c 57: Cannot convert 'void *' to 'BINLOG *' in function PE> main(int,char * *) PE> *** 1 errors in Compile *** PE> Here's a copy of line 57: - PE> bl = malloc( lc_num * sizeof(BINLOG)); The simplest cure is: bl = (BINLOG *)malloc(lc_num * sizeof(BINLOG)); but you're probably better off converting it to real C++: bl = new BINLOG[lc_num]; However, if you do the latter, you need to find the corresponding calls to free(), and convert them to: delete [] bl; This shouldn't be a terrible amount of work either, and is generally preferrable. Later, Jerry. ... The Universe is a figment of its own imagination. --- PPoint 1.90 * Origin: Point Pointedly Pointless (1:128/166.5) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EAN00004 Date: 06/15/97 From: MICHAEL LUTZ Time: 09:11pm \/To: DAVID TORREZ (Read 3 times) Subj: C++ communication library DT>3.1x, Windows 95, Windows NT, Win32s, MS-DOS, 16 and 32 bit DOS DT>extenders. Supports all popular C/C++ compilers. Windows DLL supports DT>16-bit Visual Basic. DT>All this at http://www.gleaf.com I presume there is a charge for this in some way? * SLMR 2.1a * Flowers! Is there a...John...Luck...Pickerd here? -Q --- HyperMail! v1.22 * Origin: Wizard's Tower BBS, NJ V34+ (732)-473-1933 (1:107/7010) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EAN00005 Date: 06/15/97 From: ALAN LO Time: 05:19pm \/To: DALE NOE (Read 3 times) Subj: NRI SCHools <<< I acknownledge your existence >>> DN> I have found out about a school for computer programmers. DN> if anyone wants free information about NRI SCHOOLS COMPUTER DN> PROGRAMMING. let me know and I will have then send you the information Yeah, jet me some of that. ... A bird in the hand is safer than one overhead --- Blue Wave/DOS v2.30 * Origin: Juxtaposition BBS. Lasalle, Quebec, Canada (1:167/133) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EAN00006 Date: 06/15/97 From: ALAN LO Time: 06:32pm \/To: ANTON S. MAXIMENKO (Read 3 times) Subj: which version? <<< I acknownledge your existence >>> ASM> Khmmm :) You understood my english ! Great :))) ASM> develope interface simply. No flexiblity, but you don't need it in ASM> this case... Thanx for the help. It is a bit more clear now. ... 9 out of 10 long-range snipers prefer FBI Jackboots --- Blue Wave/DOS v2.30 * Origin: Juxtaposition BBS. Lasalle, Quebec, Canada (1:167/133)