--------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200076 Date: 04/01/98 From: DAVID NOON Time: 07:51pm \/To: PAUL ROBINSON (Read 3 times) Subj: Re: Compiler In a message dated 03-29-98, Paul Robinson said to Andrew Frank about Re: Compiler Hi Paul, PR>mmm the type of compiler im looking for is one, that isnt the fastest PR>etc, i just need something that will handle the basics and some of the PR>trickier stuff PR>just something for the beginner In this echo? ROFL! The adjective "simple" does not associate very readily with the noun phrase "C++ compiler", I'm afraid. Since you are a beginner, I suggest you start by obtaining the cheapest compiler you can get that has a good reputation for robustness. The GNU compilers fill that role admirably, especially as they are free for the download. Which platform do you use? DOS/Windows? OS/2? NT? UNIX? Linux? There are free C++ compilers around for each of these, and more. Regards Dave ___ * MR/2 2.25 #353 * Hey, I ran Windows the other day, and it didn't crash! --- Maximus/2 3.01 * Origin: DoNoR/2,Woking UK (44-1483-717905) (2:440/4) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200077 Date: 04/02/98 From: KURT KUZBA Time: 05:51am \/To: JO GERAERTS (Read 3 times) Subj: convert char to int... JG> the value is a number is an I want to convert it to a JG> integer. How can do that. I tried this: JG> int x=(int)str; JG> I also tried this: JG> int x=(int)*str JG> But if for example value=10 then x becomes something JG> else. How can I convert it without changing the value? int x = atoi(str); atoi() is an ANSI standard function to convert an ascii string to an integer value. If you wanted to see how you might do this yourself: int Int_from_Ascii(const char *szS) { int iResult = 0, iSgn = 1; if(szS && *szS) for( ; *szS; szS++) if(isdigit(*szS)) { iResult = iResult * 10 + *szS - '0'; } else if('-' == *szS) iSgn = -1; return iResult * iSgn; } It isn't pretty, and it isn't quick, but it should work. atoi() is much faster and much prettier. :) > ] When you go, go as Mr. Underhill...[ Gandalf the Gray ]..... --- * Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200078 Date: 04/02/98 From: KURT KUZBA Time: 05:51am \/To: JO GERAERTS (Read 3 times) Subj: Ansi files JG> How can I use ANSi files in C++. JG> They 've got to be linked into the executable. If they are going to be text format, then they will need to be put into a function which returns the pointer to the string literal, which must be coded into the function. They may then be displayed via stdout() assuming ANSI.SYS is loaded, or interpreted to the proper color, cursor, and character commands for display. If they are stored as binary data, try this. /*_|_| ANSBIN.CPP _|_|_| A simple C++ class for handling ANSI picture data. _|_|_| No warrantee or guarantee given or implied. _|_|_| PUBLIC DOMAIN by Kurt Kuzba. (6/29/1997)*/ #include #include class AnsiImage { public: AnsiImage(char*, int, int); void display(int, int); private: char *pic; int high, wide; }; AnsiImage::AnsiImage(char *image, int h = 25, int w = 80) { pic = image; high = h; wide = w; } void AnsiImage::display(int left, int top) { short *Dst = (short*)0xb8000000l; short *Src = (short*)pic; int Ln, bytewidth = wide << 1, incD = 80; Dst += ((80 * (--top)) + (--left)); for(Ln = 0; Ln < high; Ln++) memmove(Dst, Src, bytewidth), Dst += incD, Src += wide; } char *Sttng(void) { unsigned char *STTNG = { " \x0F \x0F.\x0E \x0F\x04 \x0F \x0F \x0F.\x0E \x0F \x0F \x0F \x0F" "\x02 \x0F \x0F \x0F \x0F \x0F \x0F\x70\x70\x70\x70\x70\x70" "\x70\x70\x70\x70\x70\x70\x70\x70\x70 \x0F \x0F\x0E \x0F" " \x0F \x0F \x0F \x0F \x0F \x0F \x0F \x0F \x0F.\x0E \x0F \x0F \x0F" " \x0F\x0D \x0F\x04 \x0F \x0F\x70\x70\x70\x70\x70\x70\x70" " \x70\x7E \x70 \x70 \x70\x7E \x70 \x70 \x70 \x70\x7E \x70 \x70" " \x70\x7E \x70 \x70\x7E \x70\x7E\x7E \x70 \x70 \x70:\x7E \x70" " \x70 \x70\x7E\x7E \x70 \x70 \x70 \x70 \x70 \x70\x7E\x70\x70" "\x70\x70\x70\x70\x70 \x0F \x0F \x0F\x70\x70\x70\x70\x70" "\x70\x7E \x70 \x70\x7E \x70\x7E:\x7E \x70\x7E\x7E \x70 \x70" " \x70 \x70 \x70\x73\x73\x73s\x73s\x73:\x7E \x70\x7E \x70 \x70" "\x7E\x7E \x70 \x70 \x70 \x70\x7E \x70 \x70:\x7E \x70\x7E\x7E" "\x7E \x70 \x70 \x70\x7E\x70\x70\x70\x70\x70\x70 \x0F \x0F" ".\x0E \x0F \x0F\x0C \x0F \x0F \x0F \x0F\x70\x70\x70\x70\x70" "\x70\x70\x70 \x70\x7E \x70:\x7E \x70\x7E\x73\x73\x73h\x73" "\x73\x73 \x70 \x70\x7E \x70\x7E\x7E \x70:\x7E \x70\x70\x70" "\x70\x70\x70\x70\x70\x70 \x0F \x0F \x0F \x0F \x0F \x0F\x0C" " \x0F \x0F\x0E\x04 \x0F \x0F \x0F \x0F \x0F.\x0A \x0F \x0F\x09" "\x09\x09\x09\x09\x09\x09\x70\x70\x70\x70 \x70:\x7E \x70" "\x7E\x7E\x7E\x7E \x70 \x70\x7E\x7E\x7E\x7E \x70 \x70\x70" "\x70\x70\x70\x09\x09\x09\x09\x09\x09\x09 \x0F \x0F \x0F" "\x03 \x0F \x0F \x0F.\x01 \x0F \x0F\x0E \x0F \x0F\x0D \x0F \x0F" " \x0F.\x0E \x0F\x70\x70\x70\x70\x70\x70 \x70\x70\x0C \x0F" "\x03 \x0F.\x0D\x70\x70 \x70\x7E \x70\x7E \x70 \x70\x7E\x70" "\x70 \x0F.\x01 \x0F\x03 \x0F\x70 \x70\x70\x70\x70\x70\x70" "\x70\x0C \x0F \x0F \x0F \x0F\x0C \x0F \x0F\x0E \x0F \x0F \x0F" "\x03 \x0F.\x01 \x0F \x0F \x0F \x0F \x0F\x0E \x0F \x0F\x03 \x0F" "\x70 \x70 \x0F.\x0E \x0F\x04 \x0F.\x01 \x0F\x70\x7C\x7C\x7C" "\x7C\x7C\x70\x0E.\x0D \x0F \x0F\x0C \x0F \x0F \x70\x70 \x0F" " \x0F\x03 \x0F \x0F \x0F.\x0D \x0F\x0E \x0F \x0F \x0F \x0F.\x0E" " \x0F\x0D \x0C \x0C \x0C \x0C \x0C \x0C \x0C \x0C \x0C \x0C \x0C" " \x0C \x0F \x0F\x04 \x0F\x70 \x70\x70\x70\x70\x70\x70\x70" " \x70 \x70 \x70 \x70 \x70 \x70 \x70\x70\x70\x70\x70\x70\x70" " \x70\x70 \x0F \x0F.\x01 \x0F \x0F.\x0E \x0F \x0F \x0F \x0F\x04" " \x0F \x0F.\x03 \x0F \x0F \x0F"}; return (char*)STTNG; } int main(void) { char a; AnsiImage MyPic(Sttng(), 8, 56); MyPic.display(10, 3); cin >> a; return 0; } > ] What do you mean, "There is more to life than computers."?.. --- * Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200079 Date: 04/02/98 From: KURT KUZBA Time: 05:51am \/To: SEBASTIAN NOZZI (Read 3 times) Subj: Exceptions SN> C++ Builder & BC++ 5 SN> I would like to know which are the main differences SN> between this two programming tools. BC++5.0 is a C++ compiler and development environment. C++ Builder is, to my knowledge, an enhanced development environment for Borland C++. SN> What are streams exacly, and what can be done with them? SN> Wgat is a streamable class? A stream is a data I/O object. With streams, you can move data to and from your application, and manipulate it. A streamable class is one whose data objects may be used directly with the stream functions. SN> What are exceptions and what do they have to do with C++? SN> What are they used for? Exceptions are used to catch errors in C++. When you allocate memory, for instance, or open a file, or create an instance of a class, and there is an error in the process of doing so, it creates an exception which you may catch. You may then implement recovery code or inform the user that there has been an error in your app's operation. SN> Can I declare a function that returns an unknown type SN> (known at run-time) by value and not by reference SN> (the famous void*)? Yes. In C++ however, you will require an explicit cast to type at time of use when the value is returned, whereas, in C, the void* is automatically assigned to type in use. > ] Give me only the facts. I grow weary of all these Truths.... --- * Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200080 Date: 04/02/98 From: KURT KUZBA Time: 05:51am \/To: DAVID VAN HOOSE (Read 3 times) Subj: reading input from stdin DV> If you do that verbatim, you will have an overflow DV> problem with all known compilers. This is how that DV> should be: DV> char name[40]; DV> gets(name); DV> name[40]='\n'; DV> You have to put a NULL on the end or it will have an DV> overflow problem. I believe you have to do that with DV> 'fgets' as well.. Don't try this at home! Since name has only 40 elements, name[39] is the last one you can access. Accessing name[40] with an assignment operation writes a value to an unknown location. Rather, we KNOW where it writes it, but have no idea what SHOULD be there. This can crash your system. You don't need '\n' at the end of your string, and will often wish to strip it off when using gets() or fgets(). You want a NUL, or zero terminator, which is '\0', which gets() and fgets() will also automatically assign. It is things like this which made the stream libraries necessary, as the I/O usage is confusing at best, and can absolutely bewilder the beginner. istream getname; char name[40]; getname.getline(name, 40); or char name[40]; fgets(name, 40, stdin); if(strchr(name, '\n')) { *strchr(name, '\n') = '\0'; } else { char buf[16] = ""; do { fgets(buf, 16, stdin); } while(!strchr(buf, '\n')); } You WILL have to strip the '\n' from that second example, which is C and not C++, since it ignores stream objects and uses standard C functions instead. You also need to see if the '\n' made it into the string or if it remained in the stream buffer and needs to be flushed from it. You can see how the C++ version would be much preferred for quick development and simplified maintenance. --- > ] Wait a minute... ///\oo/\\\ Almonds don't have legs......... --- * Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200081 Date: 04/02/98 From: KURT KUZBA Time: 05:51am \/To: BILL GODFREY (Read 3 times) Subj: Sorting linked list BG> I would recommend forgetting a quick sort, and just re- BG> build a copy of the linked list in sorted form. The main BG> nice feature about linked lists is the ability to insert BG> items with the minimum of fuss. BG> Even better, sort the list stright away as you add items BG> in. Insert them in the right place to start with. BG> (That is, if it's appropiate to do so). You may have a linked list of structures, however, and wish to sort according to various elements, such as by name, or by zip code, or by city, or by age. For a database, the ability to sort the data according to varying criteria on the fly is somewhat necessary. Your database could be something as simple as a directory list, also, which you might sort by date, name, time, size, or extension, in forward or in reverse order. > ] Those who don't learn from the past are... Rats! I forgot... --- * Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200082 Date: 04/02/98 From: KURT KUZBA Time: 05:51am \/To: JABO (Read 3 times) Subj: loading a file J> now, how do i load a pcx file? in 320x200x256 ?? I have some C code to read a 320x200x256 .pcx file. The info is available in PC Game Programmer's Encyclopedia. Look for PCGPE on your local BBS's. Someone should have it. In the meantime, this code will read ONLY 320x200x256. It does not take into account pictures of different sizes or screen size or pixel color depth. You should get the C_ECHO if possible. You might add the code for variable sizes and repost the viewer as a C++ class. /*_|_| PCXVIEW.C _|_|_| A simple program to view a 320x200x256 .PCX file. _|_|_| No guarantee or warrantee is given or implied. _|_|_| Released to PUBLIC DOMAIN by Kurt Kuzba. (7/20/96)*/ #include #include #include #include void setmode(char m) { _asm{ mov ah, 00h mov al, m int 10h } } int main(int c, char *arg[]) { int index, data; long end, loc = 128, pixl = 0; char buf[768], *temp, far *mem = (char far*)0xa0000000l; FILE *fp = fopen(arg[1], "rb"); if(c < 2) { puts("usage: pcxview filename.ext"); return 1; } if(fp == NULL) { printf("Could not open %s\n", arg[1]); return 2; } fseek(fp, 0l, SEEK_END); end = ftell(fp) - 768; fseek(fp, end, SEEK_SET); fread(buf, 1, (size_t)768, fp); setmode(0x13); for(temp = &buf[0], index = 0; index < 256; index++) { outp(0x3c8, index); outp(0x3c9, *temp++ >> 2); outp(0x3c9, *temp++ >> 2); outp(0x3c9, *temp++ >> 2); } fseek(fp, loc, SEEK_SET); do { loc++; data = fgetc(fp); if((data & 0xc0) == 0xc0) { data &= 0x3f; memset(mem + (unsigned)pixl, fgetc(fp), data); pixl += data; loc++; } else *(mem + (unsigned)pixl++) = (char)data; } while(loc < end); fclose(fp); while(!kbhit()) *mem = *mem + 1; /* cycles one pixel to show its not frozen */ getch(); setmode(0x03); return 0; } /*_|_| end PCXVIEW.C */ > ] I'd say something clever, but you have nothing low-fat...... --- * Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200083 Date: 04/02/98 From: KURT KUZBA Time: 05:51am \/To: JABO (Read 3 times) Subj: heheeh J> its sad to say, but i dont have the internet J> How or where can i find the SNIPPETS packs? J> Thanks (to anyone who can help) If you absolutely cannot find it, send me your address in private netmail or internet, if you have mail capability, and I will send you a floppy with the most recent version. > ] I read Doors of Perception, but I can't remember any of it.. --- * Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200084 Date: 04/02/98 From: KURT KUZBA Time: 05:51am \/To: RICHARD VETO (Read 3 times) Subj: Programming RV> How do I link all those structures to reflect in the RV> player inventory? Do I use a union? You could, if the player is to have multiple instances of some objects. An object list would need to know what type of object is being stored, though. An equipment list, on the other hand, should be coded into the player object, and include the possibility of absence of individual items of equipment, such as no shield, or no wands. A list of each individual item type coded into the character object may serve you better and be simpler to handle. I gravitate toward making an object type, such as weapon, and having its attributes change according to type. Then you can have lists of like-type objects and limit the extent of associated confusion. The objects may be derived from a base class. > ] You're trying to make me paranoid, but I'm on to your tricks --- * Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4300000 Date: 04/02/98 From: DARRELL HNIZDOR Time: 02:40pm \/To: TIM HUTZLER (Read 2 times) Subj: Re: Modem I will send asap, let me know if it arrives. by the way on the web: HAYES modem info is available from I think hayes.com. --- Platinum Xpress/Win/Wildcat5! v2.0 * Origin: Friendship Corner Albany, TX 915-762-2745 (1:392/25)