[Dev-C++] unsubscribe : Dev-cpp-users digest
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Alfonz K. <alf...@wd...> - 2001-01-02 14:42:10
|
unsubscribe Alfonz Koncan -----Original Message----- From: dev...@li... [mailto:dev...@li...] Sent: Tuesday, January 02, 2001 8:39 AM To: dev...@li... Subject: Dev-cpp-users digest, Vol 1 #112 - 7 msgs Send Dev-cpp-users mailing list submissions to dev...@li... To subscribe or unsubscribe via the World Wide Web, visit http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users or, via email, send a message with subject or body 'help' to dev...@li... You can reach the person managing the list at dev...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of Dev-cpp-users digest..." Today's Topics: 1. RE: Divide error (Ioannis Vranos) 2. RE: [OT] C++ string vs char * (James Gordon) 3. RE: C99 (James Gordon) 4. RE: first time error return on checking file stream val idity (James Gordon) 5. RE: Change the cursor... (James Gordon) 6. RE: Connecting to a dll (James Gordon) --__--__-- Message: 1 From: "Ioannis Vranos" <no...@ya...> To: <dev...@li...> Subject: RE: [Dev-C++] Divide error Date: Tue, 2 Jan 2001 14:45:35 +0200 Reply-To: dev...@li... This is a multi-part message in MIME format. ------=_NextPart_000_001B_01C074CA.AA257050 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit do { scanf("%d", &quit); }while(quit>40000); Ioannis -----Original Message----- From: dev...@li... [mailto:dev...@li...]On Behalf Of Frazell Thomas Sent: Tuesday, January 02, 2001 4:24 AM To: dev...@li... Subject: [Dev-C++] Divide error I managed to fix the only bug i know of in my program i used an if statement but if the user enters an exit value over 40000 the program will then continue to execute reliving the bug if anyone can help me fix this new bug i would be greatly appreciative -------------------------------------PROGRAM SOURCE CODE------------------------------------------------------- // Quadrilatric equation calculater // Written by: Frazell Thomas #include <stdio.h> #include <math.h> #include <windows.h> int a,a_2,b,c,d,answer,sroot,answer_2,b_2,b_3,div,quit,quit1; int value[10]; int ctr = 0; int nbr; char plus; main() { MessageBox (NULL, "This is Q-Calc BETA 1.1 Visit http://www.FrazellThomas.com" , "Q-Calc", 0 + MB_ICONASTERISK); // Cpoyright and author information // If you alter this program you must list me in the credits // As the lead developer on this piece of software // I would also request that any version you release // Be forwarded to me at fra...@ya... // To keep me from re-inventing the wheel (programming code u already // Done) // This software it under the GNU public license printf("This program is designed to do quadratic equations only.\n"); printf("You are free to use this software as stated under the GNU\n"); printf("Public License (Avalible at GNU.org).\n\n"); printf("Version: Beta 1.1 12/12/2000 8:00PM EST.\n"); printf("Programmer: Frazell Thomas\n"); printf("Please visit http://www.frazellthomas.com\n\n"); // Input From User printf("Please enter the number used to represent varible A: "); scanf("%d", &a); quit = 40000; // if statement to prevent the divide error if the var. a is zero if (a == 0) { printf("\n\nYou entered Zero for varible A which will result in\n"); printf("\n\nNo possible answer please exit the program and run again\n"); printf("\n\nBut do not use A Zero for varible A\n"); printf("\nPlease Enter 33 To Quit\n"); scanf("%d", &quit); } if (quit <= 20000) { return 0; } printf("Please enter the number used to represent varible B: "); scanf("%d", &b_3); printf("Please enter the number used to represent varible C: "); scanf("%d", &c); //Raises varible b to the second power a_2 = pow(b_3, 2); // This is the part of out calc prog that does the work :O) // please alter + sign before var. c to a - if needed and vic versa sroot = (a_2 - 4 * a * c); b_2 = b_3 * 2; b = b_3 - b_2; div = 2 * a; answer = (b + sroot) / div; answer_2 = (b - sroot) / div; // Prints the answer printf("\nThe Answer Is %d and %d\n ", answer, answer_2); printf("\nThe square root of %d in this problem was %d\n ", b_3, sroot); printf("\n%d To the second power is %d ", b_3, a_2); // While loop do { puts("\n\nEnter 99 to quit "); scanf( "%d", &nbr); value[ctr] = nbr; ctr++; }while (ctr < 10 && nbr != 99); return 0; } ------=_NextPart_000_001B_01C074CA.AA257050 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4611.1300" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><STRONG><FONT face=3DArial color=3D#000080 size=3D2><SPAN=20 class=3D687453012-02012001>do</SPAN></FONT></STRONG></DIV> <DIV><STRONG><FONT face=3DArial color=3D#000080 size=3D2><SPAN=20 class=3D687453012-02012001>{</SPAN></FONT></STRONG></DIV> <DIV><STRONG><FONT face=3DArial color=3D#000080 size=3D2><SPAN=20 class=3D687453012-02012001>scanf("%d", = &quit);</SPAN></FONT></STRONG></DIV> <DIV><STRONG><FONT face=3DArial color=3D#000080 size=3D2><SPAN=20 class=3D687453012-02012001>}while(quit>40000);</SPAN></FONT></STRONG><= /DIV> <DIV><STRONG><FONT face=3DArial color=3D#000080 size=3D2><SPAN=20 class=3D687453012-02012001></SPAN></FONT></STRONG> </DIV> <DIV><STRONG><FONT face=3DArial color=3D#000080 size=3D2><SPAN=20 class=3D687453012-02012001></SPAN></FONT></STRONG> </DIV> <DIV><STRONG><FONT face=3DArial color=3D#000080 size=3D2><SPAN=20 class=3D687453012-02012001>Ioannis</SPAN></FONT></STRONG></DIV> <BLOCKQUOTE dir=3Dltr=20 style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000080 2px = solid; MARGIN-RIGHT: 0px"> <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT = face=3DTahoma=20 size=3D2>-----Original Message-----<BR><B>From:</B>=20 dev...@li...=20 [mailto:dev...@li...]<B>On Behalf Of = </B>Frazell=20 Thomas<BR><B>Sent:</B> Tuesday, January 02, 2001 4:24 AM<BR><B>To:</B> = dev...@li...<BR><B>Subject:</B> [Dev-C++] = Divide=20 error<BR><BR></FONT></DIV> <DIV><FONT face=3DArial size=3D2>I managed to fix the only bug i know = of in my=20 program i used an if statement but if the user enters an exit value = over 40000=20 the program will then continue to execute reliving the bug if anyone = can help=20 me fix this new bug i would be greatly appreciative</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial = size=3D2>-------------------------------------PROGRAM=20 SOURCE=20 CODE-------------------------------------------------------</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>// Quadrilatric equation = calculater<BR>// Written=20 by: Frazell Thomas<BR>#include <stdio.h><BR>#include=20 <math.h><BR>#include <windows.h><BR>int=20 a,a_2,b,c,d,answer,sroot,answer_2,b_2,b_3,div,quit,quit1;<BR>int=20 value[10];<BR>int ctr =3D 0;<BR>int nbr;<BR>char=20 plus;<BR>main()<BR>{ =20 <BR> MessageBox (NULL, "This is = Q-Calc=20 BETA 1.1</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Visit <A=20 = href=3D"http://www.FrazellThomas.com">http://www.FrazellThomas.com</A>" = ,=20 "Q-Calc", 0 + MB_ICONASTERISK);<BR> // = Cpoyright=20 and author information<BR> // If you = alter this=20 program you must list me in the = credits<BR> //=20 As the lead developer on this piece of=20 software<BR> // I would also request = that any=20 version you release<BR> // Be forwarded = to me at=20 <A=20 = href=3D"mailto:fra...@ya...">fra...@ya...</A><BR>&n= bsp; =20 // To keep me from re-inventing the wheel (programming code u=20 already<BR> //=20 Done)<BR> // This software it under the = GNU=20 public license<BR> printf("This program = is=20 designed to do quadratic equations=20 only.\n");<BR> printf("You are free to = use this=20 software as stated under the = GNU\n");<BR> =20 printf("Public License (Avalible at=20 GNU.org).\n\n");<BR> printf("Version: = Beta 1.1=20 12/12/2000 8:00PM EST.\n");<BR> =20 printf("Programmer: Frazell = Thomas\n");<BR> =20 printf("Please visit <A=20 = href=3D"http://www.frazellthomas.com\n\n">http://www.frazellthomas.com\n\= n</A>");<BR> =20 // Input From User<BR> printf("Please = enter the=20 number used to represent varible A: = ");<BR> =20 scanf("%d", &a);<BR> quit =3D=20 40000;<BR> // if statement to prevent = the divide=20 error if the var. a is = zero<BR> if=20 (a =3D=3D 0)<BR> =20 {<BR> = printf("\n\nYou=20 entered Zero for varible A which will result=20 in\n");<BR> =20 printf("\n\nNo possible answer please exit the program and run=20 again\n");<BR> =20 printf("\n\nBut do not use A Zero for varible=20 A\n");<BR> =20 printf("\nPlease Enter 33 To=20 Quit\n");<BR> =20 scanf("%d", = &quit);<BR> =20 = }<BR> = if=20 (quit <=3D=20 = 20000)<BR> &nb= sp; =20 {=20 = <BR> &nb= sp; =20 return=20 = 0;<BR> &= nbsp; =20 = } = =20 <BR> printf("Please enter the number = used to=20 represent varible B: ");<BR> scanf("%d", = &b_3);<BR> printf("Please enter the = number=20 used to represent varible C: ");<BR> = scanf("%d",=20 &c);<BR> //Raises varible b to the = second=20 power<BR> a_2 =3D pow(b_3,=20 2);<BR> // This is the part of out calc = prog=20 that does the work :O)<BR> // please = alter +=20 sign before var. c to a - if needed and vic=20 versa<BR> sroot =3D (a_2 - 4 * a *=20 c);<BR> b_2 =3D b_3 *=20 2;<BR> b =3D b_3 -=20 b_2;<BR> div =3D 2 *=20 a;<BR> answer =3D (b + sroot) /=20 div;<BR> answer_2 =3D (b - sroot) /=20 div;<BR> // Prints the=20 answer<BR> printf("\nThe Answer Is %d = and %d\n=20 ", answer, answer_2);<BR> printf("\nThe = square=20 root of %d in this problem was %d\n ", b_3,=20 sroot);<BR> printf("\n%d To the second = power is=20 %d ", b_3, a_2);<BR> =20 <BR> // While loop =20 = <BR> &nb= sp; =20 do<BR> =20 = {<BR> &n= bsp; =20 puts("\n\nEnter 99 to quit=20 = ");<BR> = =20 scanf( "%d",=20 = &nbr);<BR>  = ; =20 value[ctr] =3D=20 = nbr;<BR>  = ; =20 ctr++;<BR> }while (ctr = < 10=20 && nbr !=3D 99);<BR> return=20 0;<BR>}</FONT></DIV></BLOCKQUOTE></BODY></HTML> ------=_NextPart_000_001B_01C074CA.AA257050-- --__--__-- Message: 2 From: James Gordon <Jam...@Cl...> To: "'dev...@li...'" <dev...@li...> Subject: RE: [Dev-C++] [OT] C++ string vs char * Date: Tue, 2 Jan 2001 13:50:42 -0000 Reply-To: dev...@li... C++ Strings have a lot of the functionality of the str... type functions built into the classes. If you need to pass a char* to a function you can use c_str() which returns a char*. Best to read the doc's. There's: append - to append a char* or string. c_str - to return the underlying string as a char*. find_fist_of - to find the first occurrence of a string. resize - to allocate the memory for a string. + - add two strings together. != == > < etc. - comparison. See the string header file or docs for class members. Regards, James. -----Original Message----- From: Ramana Kumar [mailto:ra...@my...] Sent: Saturday, December 30, 2000 8:56 AM To: dev...@li... Subject: RE: [Dev-C++] [OT] C++ string vs char * I'm not too good with strings, but based on your e-mail, I would go for creating a simple string class. C++ strings become a pain depending on the things you do because they aren't compatible with char[]s and vice versa (I'm writing a game that takes in a string containing a command in English and acts accordingly, i.e. "Open door" opens the door). Using char*'s/char[]s gives you good control. I don't know what you mean by bloat/efficiency, but basically, from what I understand, I think the char*s will give more "efficiency?". The only problem with the char*s is, as you said you have to do your memory management but also some useful functions in string.h (I think) don't work on them. If some of what I'm saying is complete poppycock, I do apologise, I am going by experience, not by facts from the ISO C++ "set of rules". So as I said, I would take option b. Ramana -----Original Message----- From: dev...@li... [mailto:dev...@li...]On Behalf Of bis...@bt... Sent: Friday, December 29, 2000 9:05 PM To: dev...@li... Subject: [Dev-C++] [OT] C++ string vs char * Hi all I'm writing a small application using G++ - this one has a lot of string manipulation (It is a doxygen-like auto documentation system for a propreitory language). I seem to have three options: a) Use char *s and do my own memory management. b) Roll by own lightweight string class c) Use the C++ string class Can anyone tell me how good is the string class in terms of bloat/efficiency compared to char * ? Is (b) a viable option if what I want is basically char * with inbuild memory management ? Also, should I use (io|f|str)string ? How much of a bloat/efficiency concern is that compared to (f|s)printf/write/read and friends ? I don't plan to use the STL stuff. Thanks in advance. Biswa. _______________________________________________ Dev-cpp-users mailing list Dev...@li... http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users _______________________________________________ Dev-cpp-users mailing list Dev...@li... http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This electronic message and any attachment is intended to be read by the named addressee(s) only. Any other recipient should be aware that its contents may be legally privileged and/or confidential and that its use, disclosure, copying or distribution may be unlawful. Unless you are a named addressee, please delete this message Whilst C. & J. Clark International Limited has taken steps to prevent the transmission of computer viruses with electronic mail, responsibility for screening incoming messages and the risk of such transmission and its consequences lies with the recipient. C. & J. Clark International Limited Registered in England and Wales Company No. 141015 Registered Office: 40 High Street, Street, Somerset BA16 0YA Telephone: +44 (0) 1458 443131 Fax: +44 (0) 1458 447547 --__--__-- Message: 3 From: James Gordon <Jam...@Cl...> To: "'dev...@li...'" <dev...@li...> Subject: RE: [Dev-C++] C99 Date: Tue, 2 Jan 2001 13:53:40 -0000 Reply-To: dev...@li... For instance? Regards, James. -----Original Message----- From: Ioannis Vranos [mailto:no...@ya...] Sent: Saturday, December 30, 2000 12:17 PM To: Dev-C++ Subject: [Dev-C++] C99 Talking about C, has anybody in here realized what crap has been introduced in C, in C99 standard? The language has been totally ruined. Now i completely understand why K&R will not write a new book. Ioannis * Ioannis Vranos * Programming pages: http://members.nbci.com/noicys <http://members.nbci.com/noicys> * Alternative URL: http://run.to/noicys <http://run.to/noicys> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This electronic message and any attachment is intended to be read by the named addressee(s) only. Any other recipient should be aware that its contents may be legally privileged and/or confidential and that its use, disclosure, copying or distribution may be unlawful. Unless you are a named addressee, please delete this message Whilst C. & J. Clark International Limited has taken steps to prevent the transmission of computer viruses with electronic mail, responsibility for screening incoming messages and the risk of such transmission and its consequences lies with the recipient. C. & J. Clark International Limited Registered in England and Wales Company No. 141015 Registered Office: 40 High Street, Street, Somerset BA16 0YA Telephone: +44 (0) 1458 443131 Fax: +44 (0) 1458 447547 --__--__-- Message: 4 From: James Gordon <Jam...@Cl...> To: "'dev...@li...'" <dev...@li...> Subject: RE: [Dev-C++] first time error return on checking file stream val idity Date: Tue, 2 Jan 2001 14:18:55 -0000 Reply-To: dev...@li... 1st. You should only define your defaults in the declaration of the function, and not redefine them in the definition of the function. The reason you are not getting an error the first time you access invalid is because when it is created the state bits are set to 'good'. After you have tried to write out the state is not 'bad'. If you were to test and return if the stream isn't open (is_open() returns true if the file pointer is not a null pointer). Possibly change this: if (!output_file) { cout << "Error opening file." << endl; return 1; // error indication } to this if (!output_file.is_open()) { cout << "Error opening file." << endl; return 1; // error indication } Regards, James. -----Original Message----- From: Alan Thomas [mailto:ala...@3n...] Sent: Saturday, December 30, 2000 11:19 PM To: dev...@li... Subject: [Dev-C++] first time error return on checking file stream validity The code below gives some interesting results. First return from the function start_HTML_file is 0 (no error), while the second time it returns 1 (could not open file). What does this mean? Thanks, Alan #include <iostream.h> #include <stdlib.h> #include <fstream.h> #include <string.h> // define HTML author const char *Author = "Alan Thomas"; // // function prototype // int start_HTML_file (ofstream&output_file, char *keywords = NULL, char *title = NULL); int main() { ofstream invalid; // used to test for error opening file // Test invalid file checking cout << "Error return was " << start_HTML_file (invalid, NULL, "This is the title") << endl; cout << "Error return was " << start_HTML_file (invalid, NULL, "This is the title") << endl; system("PAUSE"); return 0; } int start_HTML_file (ofstream&output_file, char *keywords = NULL, char *title = NULL) { if (!output_file) { cout << "Error opening file." << endl; return 1; // error indication } // Write header information output_file << "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">"; output_file << endl; output_file << "<html>" << endl; output_file << "<head>" << endl; output_file << "<meta http-equiv=\"Content-Type\" content-\"text/html; charset=iso-8859-1\""; output_file << endl; output_file << "<meta name=\"Author\" content=\"" << Author << "\">" << endl; if (keywords != NULL) { output_file << "<meta name=\"KeyWords\" content=\""; output_file << keywords << ">\"" << endl; } // Write out title if (title != NULL) { output_file << "<title>"; output_file << title; output_file << "</title>" << endl; } // End header output_file << "</head>" << endl; return 0; } * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This electronic message and any attachment is intended to be read by the named addressee(s) only. Any other recipient should be aware that its contents may be legally privileged and/or confidential and that its use, disclosure, copying or distribution may be unlawful. Unless you are a named addressee, please delete this message Whilst C. & J. Clark International Limited has taken steps to prevent the transmission of computer viruses with electronic mail, responsibility for screening incoming messages and the risk of such transmission and its consequences lies with the recipient. C. & J. Clark International Limited Registered in England and Wales Company No. 141015 Registered Office: 40 High Street, Street, Somerset BA16 0YA Telephone: +44 (0) 1458 443131 Fax: +44 (0) 1458 447547 --__--__-- Message: 5 From: James Gordon <Jam...@Cl...> To: "'dev...@li...'" <dev...@li...> Subject: RE: [Dev-C++] Change the cursor... Date: Tue, 2 Jan 2001 14:31:51 -0000 Reply-To: dev...@li... See http://msdn.microsoft.com/library/psdk/winui/cursors_2mcy.htm <http://msdn.microsoft.com/library/psdk/winui/cursors_2mcy.htm> Especially note : If your application must set the cursor while it is in a window, make sure the class cursor for the specified window's class is set to NULL. If the class cursor is not NULL, the system restores the class cursor each time the mouse is moved. The cursor is not shown on the screen if the internal cursor display count is less than zero. This occurs if the application uses the <http://msdn.microsoft.com/library/psdk/winui/cursors_1gky.htm> ShowCursor function to hide the cursor more times than to show the cursor. Regards, James. -----Original Message----- From: Elias Pschernig [mailto:Eli...@ao...] Sent: Friday, December 29, 2000 6:52 PM To: dev...@li... Subject: Re: [Dev-C++] Change the cursor... Hi, I would like to know how to change the cursor in a simple dialog box based program. I know that I must use SetCursor( ) and LoadCursor( ) and ShowCursor, but I can't seem to get it working. I put this in the dialog box's initinstance: SetCursor( LoadCursor(NULL, IDC_WAIT) ); ShowCursor(TRUE); But it doesn't work, the wait curor doesn't show up. Can any one help me? Thank you in advance. I'm not using C++, but in C i have a message WM_SETCURSOR sent to my dialog procedure, maybe this is what you need ? Just put your code as response to that message and the cursor changes... * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This electronic message and any attachment is intended to be read by the named addressee(s) only. Any other recipient should be aware that its contents may be legally privileged and/or confidential and that its use, disclosure, copying or distribution may be unlawful. Unless you are a named addressee, please delete this message Whilst C. & J. Clark International Limited has taken steps to prevent the transmission of computer viruses with electronic mail, responsibility for screening incoming messages and the risk of such transmission and its consequences lies with the recipient. C. & J. Clark International Limited Registered in England and Wales Company No. 141015 Registered Office: 40 High Street, Street, Somerset BA16 0YA Telephone: +44 (0) 1458 443131 Fax: +44 (0) 1458 447547 --__--__-- Message: 6 From: James Gordon <Jam...@Cl...> To: "'dev...@li...'" <dev...@li...> Subject: RE: [Dev-C++] Connecting to a dll Date: Tue, 2 Jan 2001 14:34:13 -0000 Reply-To: dev...@li... You include the .lib file in your linker settings, this allows for compile time references to be checked etc. Your application will use the .dll file at runtime. Regards, James. -----Original Message----- From: Quentin Smith [mailto:mac...@bi...] Sent: Sunday, December 31, 2000 5:51 PM To: dev...@li... Subject: [Dev-C++] Connecting to a dll Hi- I am investigating a library. It installs ok, and I have sorted out the header issues, but they only provide a .lib file and a .dll file. I know there is a .lib-to-.a converter out there, but I am unable to find it. However, is it possible to link my program with the dll at linking time? The only errors I get with my program are undefined symbols during linking. --Quentin * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This electronic message and any attachment is intended to be read by the named addressee(s) only. Any other recipient should be aware that its contents may be legally privileged and/or confidential and that its use, disclosure, copying or distribution may be unlawful. Unless you are a named addressee, please delete this message Whilst C. & J. Clark International Limited has taken steps to prevent the transmission of computer viruses with electronic mail, responsibility for screening incoming messages and the risk of such transmission and its consequences lies with the recipient. C. & J. Clark International Limited Registered in England and Wales Company No. 141015 Registered Office: 40 High Street, Street, Somerset BA16 0YA Telephone: +44 (0) 1458 443131 Fax: +44 (0) 1458 447547 --__--__-- _______________________________________________ Dev-cpp-users mailing list Dev...@li... http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users End of Dev-cpp-users Digest |