dev-cpp-users Mailing List for Dev-C++ (Page 500)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
| 2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
| 2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
| 2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
| 2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
| 2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
| 2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
| 2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
| 2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
| 2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
| 2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
| 2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
| 2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Per W. <pw...@ia...> - 2002-10-24 23:12:36
|
Not completely sure :-) You should ave __WXMSW__ defined too. For one of my wxWindows projects, I have the following settings: The General/Compiler options: -fno-rtti -fno-exceptions -fno-pcc-struct-return -fstrict-aliasing -Wall -fvtable-thunks -D_X86_=1 -DWIN32 -D_WIN32 -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -D__WIN32__ -DSTRICT -D__WXMSW__ -D__WINDOWS__ -D__WXDEBUG__ -Wno-multichar The General/Linker options: -Wl --subsystem,windows -mwindows -lwxmswd -lregex -ljpeg -lpng -lzlib -ltiff -lstdc++ -lgcc -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid General/Type: Win32 GUI The project is using wxWindows 2.3.3 build from the source distribution on sourceforge, i.e. not the wxWindows package available for Dev-C++. Compilation with MinGW. gcc 2.95.3-6. /Per W On Thu, 24 Oct 2002 XI...@pr... wrote: > And that will fix the unsupported toolkit error in fonts.h? > > Cool. > (PS-I did not see your response amongst the digests from that > period...) > > --- Original Message --- > From: dev...@li... > To: dev...@li... > Subject: Dev-cpp-users digest, Vol 1 #1071 - 9 msgs > > >Send Dev-cpp-users mailing list submissions to > > > dev...@li... > > > >To subscribe or unsubscribe via the World Wide Web, visit > > > https://lists.sourceforge.net/lists/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: WxWINDOWS and Dev-C++ (Per Westermark) > > 2. 4.9.6.5 bug (Carlos =3D?iso-8859-1?Q?Garc=3DEDa?=3D del Monte) > > 3. Re: Input one file output another. (Daniel Glenfield) > > 4. Re: drawing in Windows (Daniel Glenfield) > > 5. Re: Whoops - drawing in Windows (Daniel Glenfield) > > 6. RE : [Dev-C++] How to keep the DOS console open? (Pierre > Lepage) > > 7. Re: RE : [Dev-C++] How to keep the DOS console open? > (Daniel Glenfi= > >eld) > > 8. Strange phenomenon (Christian Wallukat) > > 9. Re: Whoops - drawing in Windows (Vlada Djurovic) > > > >--__--__-- > > > >Message: 1 > >Date: Thu, 24 Oct 2002 11:36:49 +0200 (CEST) > >From: Per Westermark <pw...@ia...> > >Reply-To: Per Westermark <pw...@ia...> > >To: David Scott Williams <xi...@pr...> > >cc: dev...@li... > >Subject: RE: [Dev-C++] WxWINDOWS and Dev-C++ > > > >Hello David! > > > >As a regular user of sourceforge, you should know that > sourceforge keeps > >the archive of this mailing list. You only have to scan two days > back to > >find your specific question, and an answer. > > > >/Per W > > > >On Mon, 21 Oct 2002, Per Westermark wrote: > > > >> The problem is that you have forgotten do define which compiler > >> environment you are using. > >>=3D20 > >> Deefine __GNUWIN32__ and wxWindows will select a suitable > string compar= > >e > >> function. > >>=3D20 > >> A good trick when playing along with the wxWindows kit is to > run the > >> makefiles in the samples directory. When they compile the > code, you wil= > >l > >> see a number of parameters sent to gcc. If you make sure that > your own > >> projects uses the same parameters, you will be home-free. > >>=3D20 > >> You will get all needed libraries, same settings for run-time type > >> information, debug settings etc. > >>=3D20 > >> /Per W > >>=3D20 > >> On Mon, 21 Oct 2002, Santiago Palmier Campos wrote: > >>=3D20 > >> > Hi Mark, > >> >=3D20 > >> > This error may appear due to... > >> >=3D20 > >> > ...uncomplete/wrong build of wxWindows libraries; so you > have to rebu= > >il=3D > >d the > >> > libraries correctly. > >> >=3D20 > >> > ...wrong order for include directories, please check them > and take a = > >lo=3D > >ok > >> > at: > >> > > http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Directory-Options.html#Dire= > >ct=3D > >ory%2 > >> > 0Options > >> > I think it is really useful sometimes ;o) > >> >=3D20 > >> > Hope this helps! > >> > Regards > >> >=3D20 > >> > Santy > >> > PS: wxWindows is not so hard/difficult to use, just be a > little bit p= > >at=3D > >ient > >> > at the beginning, follow the README instructions and take a > look at s= > >om=3D > >e > >> > tutorials, they are great!!! Just my 2 cents! > >> >=3D20 > >> > -----Original Message----- > >> > From: Mark L. Wise [mailto:ma...@al...]=3D20 > >> > Sent: s=3DE1bado, 19 de octubre de 2002 0:03 > >> > To: dev...@li... > >> > Subject: [Dev-C++] WxWINDOWS and Dev-C++ > >> >=3D20 > >> >=3D20 > >> > Hello all! > >> >=3D20 > >> > Sorry to be such a pain regarding WxWINDOWS and Dev-C++, but.... > >> >=3D20 > >> > I have been trying to compile some of the sample code > included with t= > >he > >> > WxWINDOWS package. When I try compiling I get the following > message = > >(a=3D > >long > >> > with other things...) > >> >=3D20 > >> > 4 C:\PROGRAM FILES\DEV-C++\include\wx\string.h:170 > >> > #error "Please define string case-insensitive compare for > your OS/com= > >pi=3D > >ler" > >> >=3D20 > >> > So... How do I define string case-insensitive compare in > Dev-C++??? > >> >=3D20 > >> > Thanks in advance... > >> >=3D20 > >> > Mark > >> >=3D20 > >> > Alpha II Service, Inc. > >> > 1312 Epworth Avenue > >> > Reynoldsburg, Ohio 43068 > >> > 614 868-5033 (Voice) > >> > 617 812-5838 (Fax) > >> >=3D20 > >> >=3D20 > >> >=3D20 > >> >=3D20 > >> > ------------------------------------------------------- > >> > This sf.net email is sponsored by:ThinkGeek > >> > Welcome to geek heaven. > >> > http://thinkgeek.com/sf > _____________________________________________= > >__ > >> > Dev-cpp-users mailing list > >> > Dev...@li... > >> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > >> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > >> > > ---------------------------------------------------------------------= > >--=3D > >--------------- > >> > This message and any files transmitted with it are > confidential and i= > >nt=3D > >ended solely=3D20 > >> > for the use of the individual or entity to whom they are > addressed. N= > >o =3D > >confidentiality=3D20 > >> > or privilege is waived or lost by any wrong transmission.=3D20 > >> > If you have received this message in error, please > immediately destro= > >y =3D > >it and kindly=3D20 > >> > notify the sender by reply email. > >> > You must not, directly or indirectly, use, disclose, > distribute, prin= > >t,=3D > > or copy any=3D20 > >> > part of this message if you are not the intended recipient. > Opinions,= > > c=3D > >onclusions and=3D20 > >> > other information in this message that do not relate to the > official = > >bu=3D > >siness of=3D20 > >> > Ydilo Advanced Voice Solutions, S.A. shall be understood as > neither g= > >iv=3D > >en nor endorsed by it.=3D20 > >> > > ---------------------------------------------------------------------= > >--=3D > >--------------- > >> >=3D20 > >> >=3D20 > >> > ------------------------------------------------------- > >> > This sf.net email is sponsored by:ThinkGeek > >> > Welcome to geek heaven. > >> > http://thinkgeek.com/sf > >> > _______________________________________________ > >> > Dev-cpp-users mailing list > >> > Dev...@li... > >> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > >> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > >> >=3D20 > >>=3D20 > >>=3D20 > > > > > > > > > >--__--__-- > > > >Message: 2 > >Date: Thu, 24 Oct 2002 11:17:18 +0200 > >From: Carlos =3D?iso-8859-1?Q?Garc=3DEDa?=3D del Monte <cg...@wo...> > >To: dev-cpp-users-list <dev...@li...> > >Subject: [Dev-C++] 4.9.6.5 bug > > > >I updated Dev to the 4.9.6.5 version, now the import MSVisual > project > >does not work, I select the dsp file and when I click on import > button > >it does nothing. > > > > > > > >--__--__-- > > > >Message: 3 > >From: "Daniel Glenfield" <sp...@ho...> > >To: Tam...@dl..., > dev...@li... > >Subject: Re: [Dev-C++] Input one file output another. > >Date: Thu, 24 Oct 2002 10:43:30 +0100 > > > > > >This constructor may help > >fstream( const char* szName, int nMode, int nProt =3D > filebuf::openprot )= > >; > > > >szName is the name of the file, > >nMode is ios::in, ios::out etc. > >then use > >filebuf::sh_read (Read sharing allowed.) > >and > >filebuf::sh_write (Write sharing allowed.) > >with the || operator. > > > > > >Try closing the file as well once you are done with it. > > > > > >>From: "Mitchell, Tamra (DLM)" <Tam...@dl...> > >>To: "'dev...@li...'"=20 > >><dev...@li...> > >>Subject: [Dev-C++] Input one file output another. > >>Date: Wed, 23 Oct 2002 14:54:20 -0400 > >> > >> > >>Rephrase question. > >> > >>I am trying read test from one file and output to another file > and am no= > >t > >>sure how to complete correctly. > >> > >>#include<fstream> > >>#include<iostream> > >>using namespace std; > >> > >>void main(){ > >> ifstream fin; > >> ofstream fout; > >> fin.open("Eb.txt"); > >> /*if(fin=3D=3D0){ > >> > cout << " input file xx.txt not found "<< endl; > >> }*/ > >> fout.open("y.txt"); > >> int a[10],i; > >> for(i=3D0;i<10;i++) > >> > fin >> a[i]; > >> for(i=3D0;i<10;i++) > >> > fout << a[i] << endl; > >> > >>} > >> > >> > >>Can anyone offer any suggestions. > >> > >>Tamra Y. Mitchell > >>Database & Operating Systems Analyst > >>412-222-8203 - Work > >>412-996-9078 - Cell > >> > > > > > >_________________________________________________________________ > >Surf the Web without missing calls!=A0Get MSN Broadband. =20 > >http://resourcecenter.msn.com/access/plans/freeactivation.asp > > > > > > > >--__--__-- > > > >Message: 4 > >From: "Daniel Glenfield" <sp...@ho...> > >To: dj...@im..., dev...@li... > >Subject: Re: [Dev-C++] drawing in Windows > >Date: Thu, 24 Oct 2002 10:45:02 +0100 > > > >Yes you need to serialise the information to a file. I'll see if > I can di= > >g=20 > >up some information on this, but that's what you need to do. > > > > > > > > > > > > > >>From: "Vlada Djurovic" <dj...@im...> > >>To: "'DevC++ help'" <dev...@li...> > >>Subject: [Dev-C++] drawing in Windows > >>Date: Thu, 24 Oct 2002 10:32:16 +0200 > >> > >>Hi, everybody > >>Here's my problem: I'm trying to write a simple drawing app > (just for=20 > >>exercise) and so far its been going OK. I can draw lines in > client area = > >in=20 > >>different colors, but when ever I minimize or maximize the > window, or=20 > >>something similar happenes, all the content of the window is > gone. I tri= > >ed=20 > >>to use a memory DC an bitmap to save the contents in, and > BitBlt it back= > > in=20 > >>response to WM_PAINT message, but the program just "froze". Can > anybody=20 > >>give me a hint how to do it? Here's the code used for drawing > lines with= > >out=20 > >>any restoring parts: > >> > >> case WM_MOUSEMOVE: > >> { > >> switch(iTool) /* iTool is used for > dtetrmining wh= > >ich=20 > >>drawing tool is selected(line, rect etc.)*/ > >> { > >> case 0: > >> { > >> if(wParam=3D=3DMK_LBUTTON) /*if line is > selected=20 > >>(itool=3D0) and left button presed*/ > >> { > >> HDC hDC=3DGetDC(hwnd); > >> > >> HPEN > hPen=3DCreatePen(PS_SOLID,iCurWidth,crCurCo= > >lor); > >> HPEN > hOldPen=3D(HPEN)SelectObject(hDC,hPen); > >> CLine* pLine=3Dnew=20 > >>CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); > /*create new l= > >ine=20 > >>object*/ > >> pLine->DrawLine(hDC); > >> ptPrevPos=3DMAKEPOINTS(lParam); > >> SelectObject(hDC,hOldPen); > >> DeleteDC(hDC); > >> } > >> } > >> break; > >> case 1: /* nothing here yet*/ > >> break; > >> } > >> } > > > > > >_________________________________________________________________ > >Protect your PC - get McAfee.com VirusScan Online=20 > >http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3D3963 > > > > > > > >--__--__-- > > > >Message: 5 > >From: "Daniel Glenfield" <sp...@ho...> > >To: dj...@im..., dev...@li... > >Subject: Re: [Dev-C++] Whoops - drawing in Windows > >Date: Thu, 24 Oct 2002 10:59:19 +0100 > > > >Nope maybe not, serialising is for saving and restoring. > > > >I think you have to store the info in to an array, but looking > at this ol= > >d=20 > >code I cannot remember what exactly you have to do. I worked on > the Scrib= > >ble=20 > >tutorial that comes with VC++ - have a look on MSDN for it. > > > > > > > >>From: "Vlada Djurovic" <dj...@im...> > >>To: "'DevC++ help'" <dev...@li...> > >>Subject: [Dev-C++] drawing in Windows > >>Date: Thu, 24 Oct 2002 10:32:16 +0200 > >> > >>Hi, everybody > >>Here's my problem: I'm trying to write a simple drawing app > (just for=20 > >>exercise) and so far its been going OK. I can draw lines in > client area = > >in=20 > >>different colors, but when ever I minimize or maximize the > window, or=20 > >>something similar happenes, all the content of the window is > gone. I tri= > >ed=20 > >>to use a memory DC an bitmap to save the contents in, and > BitBlt it back= > > in=20 > >>response to WM_PAINT message, but the program just "froze". Can > anybody=20 > >>give me a hint how to do it? Here's the code used for drawing > lines with= > >out=20 > >>any restoring parts: > >> > >> case WM_MOUSEMOVE: > >> { > >> switch(iTool) /* iTool is used for > dtetrmining wh= > >ich=20 > >>drawing tool is selected(line, rect etc.)*/ > >> { > >> case 0: > >> { > >> if(wParam=3D=3DMK_LBUTTON) /*if line is > selected=20 > >>(itool=3D0) and left button presed*/ > >> { > >> HDC hDC=3DGetDC(hwnd); > >> > >> HPEN > hPen=3DCreatePen(PS_SOLID,iCurWidth,crCurCo= > >lor); > >> HPEN > hOldPen=3D(HPEN)SelectObject(hDC,hPen); > >> CLine* pLine=3Dnew=20 > >>CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); > /*create new l= > >ine=20 > >>object*/ > >> pLine->DrawLine(hDC); > >> ptPrevPos=3DMAKEPOINTS(lParam); > >> SelectObject(hDC,hOldPen); > >> DeleteDC(hDC); > >> } > >> } > >> break; > >> case 1: /* nothing here yet*/ > >> break; > >> } > >> } > > > > > >_________________________________________________________________ > >Get a speedy connection with MSN Broadband.=A0 Join now!=20 > >http://resourcecenter.msn.com/access/plans/freeactivation.asp > > > > > > > >--__--__-- > > > >Message: 6 > >Date: Thu, 24 Oct 2002 06:45:59 -0400 > >From: Pierre Lepage <fam...@gl...> > >Subject: RE : [Dev-C++] How to keep the DOS console open? > >To: da...@ir... > >Cc: dev...@li... > > > >C'est un message de format MIME en plusieurs parties. > > > >--Boundary_(ID_67V4hQiqD3A0FRmuYaAghQ) > >Content-type: text/plain; charset=3Diso-8859-1 > >Content-transfer-encoding: QUOTED-PRINTABLE > > > >You must send a command to DOS to pause for sometime. > > > >The solution look like this : > > > > > >#include <cstdlib> // function system > > > > > >=3D85 > > > >void main { > > > >=3D85 your programm > > > > system(=3D93PAUSE=3D94); > > > >} // end of main. > > > > > >--Boundary_(ID_67V4hQiqD3A0FRmuYaAghQ) > >Content-type: text/html; charset=3Diso-8859-1 > >Content-transfer-encoding: QUOTED-PRINTABLE > > > ><html xmlns:o=3D3D"urn:schemas-microsoft-com:office:office" > xmlns:w=3D > >=3D3D"urn:schemas-microsoft-com:office:word" > xmlns=3D3D"http://www.w3.org= > >=3D > >/TR/REC-html40"> > > > ><head> > ><meta http-equiv=3D3DContent-Type content=3D3D"text/html; > charset=3D3Diso= > >-8=3D > >859-1"> > ><meta name=3D3DProgId content=3D3DWord.Document> > ><meta name=3D3DGenerator content=3D3D"Microsoft Word 9"> > ><meta name=3D3DOriginator content=3D3D"Microsoft Word 9"> > ><link rel=3D3DFile-List > href=3D3D"cid:filelist.xml@01C27B28.FCB62920"> > ><!--[if gte mso 9]><xml> > > <o:OfficeDocumentSettings> > > <o:DoNotRelyOnCSS/> > > </o:OfficeDocumentSettings> > ></xml><![endif]--><!--[if gte mso 9]><xml> > > <w:WordDocument> > > <w:View>Normal</w:View> > > <w:Zoom>0</w:Zoom> > > <w:DocumentKind>DocumentEmail</w:DocumentKind> > > <w:HyphenationZone>21</w:HyphenationZone> > > <w:EnvelopeVis/> > > <w:DrawingGridHorizontalSpacing>5 > pt</w:DrawingGridHorizontalSpacin=3D > >g> > > <w:DrawingGridVerticalSpacing>8.15 > pt</w:DrawingGridVerticalSpacing=3D > >> > > > <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingG=3D > >ridEvery> > > > <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridE=3D > >very> > > <w:Compatibility> > > <w:FootnoteLayoutLikeWW8/> > > <w:ShapeLayoutLikeWW8/> > > <w:AlignTablesRowByRow/> > > <w:ForgetLastTabAlignment/> > > <w:DoNotUseHTMLParagraphAutoSpacing/> > > <w:LayoutRawTableWidth/> > > <w:LayoutTableRowsApart/> > > </w:Compatibility> > > </w:WordDocument> > ></xml><![endif]--> > ><style> > ><!-- > > /* Style Definitions */ > >p.MsoNormal, li.MsoNormal, div.MsoNormal > >=3D09{mso-style-parent:""; > >=3D09margin:0in; > >=3D09margin-bottom:.0001pt; > >=3D09mso-pagination:widow-orphan; > >=3D09font-size:10.0pt; > >=3D09font-family:"Times New Roman"; > >=3D09mso-fareast-font-family:"Times New Roman";} > >p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig > >=3D09{margin:0in; > >=3D09margin-bottom:.0001pt; > >=3D09mso-pagination:widow-orphan; > >=3D09font-size:10.0pt; > >=3D09font-family:"Times New Roman"; > >=3D09mso-fareast-font-family:"Times New Roman";} > >span.StyleCourrierlectronique15 > >=3D09{mso-style-type:personal-compose; > >=3D09mso-ansi-font-size:10.0pt; > >=3D09mso-ascii-font-family:Arial; > >=3D09mso-hansi-font-family:Arial; > >=3D09mso-bidi-font-family:Arial; > >=3D09color:black;} > >@page Section1 > >=3D09{size:595.25pt 841.85pt; > >=3D09margin:56.7pt 56.7pt 56.7pt 56.7pt; > >=3D09mso-header-margin:.5in; > >=3D09mso-footer-margin:.5in; > >=3D09mso-paper-source:0;} > >div.Section1 > >=3D09{page:Section1;} > >--> > ></style> > ></head> > > > ><body lang=3D3DFR-CA style=3D3D'tab-interval:35.4pt'> > > > ><div class=3D3DSection1> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'>You must send a command to DOS to > paus=3D > >e for > >sometime.<o:p></o:p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'><![if > !supportEmptyParas]> <![end=3D > >if]><o:p></o:p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'>The solution look like this > :<o:p></o:=3D > >p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'><![if > !supportEmptyParas]> <![end=3D > >if]><o:p></o:p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'><![if > !supportEmptyParas]> <![end=3D > >if]><o:p></o:p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'>#include <cstdlib><span > >style=3D3D"mso-spacerun: yes"> </span>// function > system<o:p></o:=3D > >p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'><![if > !supportEmptyParas]> <![end=3D > >if]><o:p></o:p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'><![if > !supportEmptyParas]> <![end=3D > >if]><o:p></o:p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'>…<o:p></o:p></span></font></span=3D > >></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'><![if > !supportEmptyParas]> <![end=3D > >if]><o:p></o:p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'>void main > {<o:p></o:p></span></font></=3D > >span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'><![if > !supportEmptyParas]> <![end=3D > >if]><o:p></o:p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'>… your > programm<o:p></o:p></span=3D > >></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'><![if > !supportEmptyParas]> <![end=3D > >if]><o:p></o:p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'><span style=3D3D"mso-spacerun: > >yes"> </span>system(“PAUSE”);<o:p></o:p></span></fon=3D > >t></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'><![if > !supportEmptyParas]> <![end=3D > >if]><o:p></o:p></span></font></span></p> > > > ><p class=3D3DMsoNormal><span > class=3D3DStyleCourrierlectronique15><font s= > >=3D > >ize=3D3D2 > >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA > style=3D3D'font-size:= > >10.0=3D > >pt;font-family: > >Arial;mso-ansi-language:EN-CA'>} // end of > main.<o:p></o:p></span></f=3D > >ont></span></p> > > > ></div> > > > ></body> > > > ></html> > > > > > >--Boundary_(ID_67V4hQiqD3A0FRmuYaAghQ)-- > > > > > >--__--__-- > > > >Message: 7 > >From: "Daniel Glenfield" <sp...@ho...> > >To: dev...@li... > >Subject: Re: RE : [Dev-C++] How to keep the DOS console open? > >Date: Thu, 24 Oct 2002 12:19:45 +0100 > > > >lol hasn't this been asked almost as much as the "how do I > unsubscribe"=20 > >question? Maybe Ioannis can put a page on his website to detail > the=20 > >different methods? > > > > > > > >>From: Pierre Lepage <fam...@gl...> > >>To: da...@ir... > >>CC: dev...@li... > >>Subject: RE : [Dev-C++] How to keep the DOS console open? > >>Date: Thu, 24 Oct 2002 06:45:59 -0400 > >> > >>You must send a command to DOS to pause for sometime. > >> > >>The solution look like this : > >> > >> > >>#include <cstdlib> // function system > >> > >> > >>=85 > >> > >>void main { > >> > >>=85 your programm > >> > >> system(=93PAUSE=94); > >> > >>} // end of main. > >> > > > > > >_________________________________________________________________ > >Protect your PC - get McAfee.com VirusScan Online=20 > >http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3D3963 > > > > > > > >--__--__-- > > > >Message: 8 > >From: Christian Wallukat <Chr...@vo...> > >To: "Dev-Cpp-Users@Lists. Sourceforge. Net (E-Mail)" > > > <dev...@li...> > >Date: Thu, 24 Oct 2002 13:51:23 +0200 > >Subject: [Dev-C++] Strange phenomenon > > > >Hi List, > > > > > >i have a strange phenomenon in my project: > > > >I call a function: Test(char szTest[1024]) with Test("test"); > > > >In that function another Function (like the first) will be called: > >Test2(szTest); > > > >the adress of szZest is 0x000000000.... > > > >and the content is empty .... > > > > > >Anyone an Idea ???? > > > >Kind r > > > >Chris > > > > > >--__--__-- > > > >Message: 9 > >From: "Vlada Djurovic" <dj...@im...> > >To: "Daniel Glenfield" <sp...@ho...>, > > > <dev...@li...> > >Subject: Re: [Dev-C++] Whoops - drawing in Windows > >Date: Thu, 24 Oct 2002 14:02:32 +0200 > > > > > >----- Original Message ----- > >From: "Daniel Glenfield" <sp...@ho...> > >To: <dj...@im...>; <dev...@li...> > >Sent: Thursday, October 24, 2002 11:59 AM > >Subject: Re: [Dev-C++] Whoops - drawing in Windows > > > > > >> Nope maybe not, serialising is for saving and restoring. > >> > >> I think you have to store the info in to an array, but looking > at this = > >old > >> code I cannot remember what exactly you have to do. I worked > on the > >Scribble > >> tutorial that comes with VC++ - have a look on MSDN for it. > >> > >> > >I tried to store all the info in a linked list, but I think I > did somethi= > >ng > >wrong because the program just froze when I tried to draw > something. Then= > > I > >thought it would be easier to store the drawing in a compatible > memory > >bitmap and then just copy it back in the client area when it > needs to be > >redrawn, but this also didn't work because the program froze > again. That'= > >s > >why I was asking if anyone can give me some guidelines about how > to do th= > >is > >(the bitmap way). > >As for the tutorials, I read the book "Teach yourself VC++ in 21 > days" wh= > >ich > >also has some stuff about this, but although I think I did > everything the > >way it's done in VC++- it doesn't work. > > > >Regards, Vlada > >> > >> >From: "Vlada Djurovic" <dj...@im...> > >> >To: "'DevC++ help'" <dev...@li...> > >> >Subject: [Dev-C++] drawing in Windows > >> >Date: Thu, 24 Oct 2002 10:32:16 +0200 > >> > > >> >Hi, everybody > >> >Here's my problem: I'm trying to write a simple drawing app > (just for > >> >exercise) and so far its been going OK. I can draw lines in > client are= > >a > >in > >> >different colors, but when ever I minimize or maximize the > window, or > >> >something similar happenes, all the content of the window is > gone. I > >tried > >> >to use a memory DC an bitmap to save the contents in, and > BitBlt it ba= > >ck > >in > >> >response to WM_PAINT message, but the program just "froze". > Can anybod= > >y > >> >give me a hint how to do it? Here's the code used for drawing > lines > >without > >> >any restoring parts: > >> > > >> > case WM_MOUSEMOVE: > >> > { > >> > switch(iTool) /* iTool is used for > dtetrmining > >which > >> >drawing tool is selected(line, rect etc.)*/ > >> > { > >> > case 0: > >> > { > >> > if(wParam=3D=3DMK_LBUTTON) /*if line > is selecte= > >d > >> >(itool=3D0) and left button presed*/ > >> > { > >> > HDC hDC=3DGetDC(hwnd); > >> > > >> > HPEN > >hPen=3DCreatePen(PS_SOLID,iCurWidth,crCurColor); > >> > HPEN > hOldPen=3D(HPEN)SelectObject(hDC,hPen); > >> > CLine* pLine=3Dnew > >> >CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); > /*create new > >line > >> >object*/ > >> > pLine->DrawLine(hDC); > >> > ptPrevPos=3DMAKEPOINTS(lParam); > >> > SelectObject(hDC,hOldPen); > >> > DeleteDC(hDC); > >> > } > >> > } > >> > break; > >> > case 1: /* nothing here yet*/ > >> > break; > >> > } > >> > } > >> > >> > >> _________________________________________________________________ > >> Get a speedy connection with MSN Broadband. Join now! > >> http://resourcecenter.msn.com/access/plans/freeactivation.asp > >> > > > > > > > > > >--__--__-- > > > >_______________________________________________ > >Dev-cpp-users mailing list > >Dev...@li... > >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > >End of Dev-cpp-users Digest > > ~Dave > ||* Projects, active *|| > Dustyscript (children programming): > >http://dustyscript.sourceforge.net/< > xTable: http://cxtable.sourceforge.net/ > Grapevine: http://grapevineproject.org/ > > > > ------------------------------------------------------- > This sf.net email is sponsored by: Influence the future > of Java(TM) technology. Join the Java Community > Process(SM) (JCP(SM)) program now. > http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0003en > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Per W. <pw...@ia...> - 2002-10-24 22:53:08
|
Ah, I did manage to add a bit of C++ in my example of storing different
object types in a vector.
Every reference to "Circle", "Line", "Box" should of course be
"struct Circle", "struct Line" and "struct Box".
And of course all // comments should be /* comment */
What can I say. I kinda prefer C++ to C. Downgrading is a bit like having
one arm tied up behind the back.
/Per W
On Fri, 25 Oct 2002, Per Westermark wrote:
> Well Ioannis, I did manage to get a star on the wrong side of the struct
> type name, see inserted correction below, so the example was slightly
> broken. However, the example was not a total goose chase try at a
> two-dimensional matrix of entries, but an example of creating a
> one-dimensional matrix (a vector) of pointers to single entries, which was
> exactly what the heading suggested "array of pointers to entries". If the
> code wasn't obvious, a hint to that fact should have been that I only
> used a single for loop to assign values to the entries.
>
> One reason to use alternative two, a vector of pointers to elements
> instead of a vector of elements, is that sorting of the vector only
> require changing the place of the pointers, instead of copying the full
> structures.
>
> Another reason is that it might be used to create a sparse matrix, where
> the vector might be very long, but only some index values of the vector
> will have an allocated entry.
>
> A third reason is that a vector of pointers might be to store different
> types of structs in the same vector, as in:
>
> enum {
> CIRCLE,
> LINE,
> BOX
> };
>
> struct Circle {
> int type;
> int x,y;
> int radius;
> };
>
> struct Line {
> int type;
> int x1,y1,x2,y2;
> }
>
> struct Box {
> int type;
> int x1,y1,x2,y2;
> };
>
> void fill_array() {
> Circle *pCircle;
> Line *pLine;
> Box *pBox;
> int item_count,i;
>
> item_count = 0;
> pCircle = (Circle*)malloc(sizeof(Circle));
> pCircle->type = CIRCLE;
> pCircle->x = 10;
> pCircle->y = 20;
> pCircle->radius = 5;
> myarray[item_count++] = pCircle;
>
> pBox = (Box*)malloc(sizeof(Box));
> pBox->type = BOX;
> pBox->x1 = 15;
> pBox->y1 = 2;
> pBox->x2 = 18;
> pBox->y2 = 5;
> myarray[item_count++] = pBox;
>
> ...
>
> // Draw items.
> for (i = 0; i < item_count; i++) {
> if (myarray[i]) {
> switch (myarray[i]->type) {
> case CIRCLE:
> pCircle = (Circle*)myarray[i];
> // Draw circle
> break;
> case BOX:
> pBox = (Box*)myarray[i];
> // Draw box
> break;
> case LINE:
> pLine = (Line*)myarray[i];
> // Draw line
> break;
> default:
> // Complain about unsupported object type.
> }
> }
> }
>
>
> By the way, to clean a vector of pointers to objects would require:
> for (i = 0; i < count; i++)
> free(myarray[i]); // Release individual elements
> free(myarray); // Release array of pointers
>
> /Per W
>
> On Thu, 24 Oct 2002, Ioannis Vranos wrote:
>
> > > -----Original Message-----
> > > From: dev...@li...
> > > [mailto:dev...@li...] On Behalf
> > > Of Per Westermark
> > > Sent: Thursday, October 24, 2002 4:13 PM
> > > To: Scott Williams
> > > Cc: dev...@li...
> > > Subject: Re: [Dev-C++] dynamic allocation and structs
> > >
> > >
> > >
> > > // Alternative 1, array of entries.
> > > mystruct *myarray;
> > > void func(int count) {
> > > int i;
> > > myarray = (mystruct*)malloc(count*sizeof(mystruct));
> > > for (i = 0; i < count; i++) {
> > > myarray[i].xx = yy;
> > > }
> > > }
> > >
> > > // Alternative 2, array of pointers to entries.
> > > mystruct **myarray;
> > > void func(int count) {
> > > int i;
> > > myarray = (mystruct**)malloc(count*sizeof(*mystruct));
> ======> myarray = (mystruct**)malloc(count*sizeof(mystruct*));
> > > for (i = 0; i < count; i++) {
> > > myarray[i] = (mystruct*)malloc(sizeof(mystruct));
> > > myarray[i]->xx = yy;
> > > }
> > > }
> >
> >
> > The Alternative 2 is wrong. You use a ** pointer and then you assign
> > values as if it is a *.
> No, I use a ** pointer to assign an array of pointers.
> Then I use a * pointer to assign an entry.
> >
> >
> > A working example of what you are trying to do:
> A working example of something I didn't tried to do :-)
> >
> > #include <stdlib.h>
> > #include <stdio.h>
> >
> > int main()
> > {
> > struct mystruct
> > {
> > int x;
> > };
> >
> > struct mystruct **myarray;
> >
> > int i, j;
> >
> > /* sizeof(*myarray)==sizeof(struct mystruct *) */
> > myarray=malloc(100*sizeof(*myarray));
> >
> > /* sizeof(**myarray)==sizeof(struct mystruct).
> > A 200x100 array on the free store is created */
> > for(i=0; i<100; i++)
> > myarray[i]=malloc(200*sizeof(**myarray));
> >
> > /* Do something */
> > for(i=0; i<100; i++)
> > for(j=0; j<200; j++)
> > {
> > myarray[i][j].x=i+j;
> >
> > printf("%d\n", myarray[i][j].x);
> > }
> >
> >
> > for(i=0; i<100; i++)
> > free(myarray[i]);
> >
> > free(myarray);
> >
> > return 0;
> > }
> >
> >
> >
> >
> > Alternative 3 (which must be prefered if possible instead of A-2):
> >
> > #include <stdlib.h>
> >
> > int main()
> > {
> > struct mystruct
> > {
> > int x;
> > };
> >
> > struct mystruct (*myarray)[100];
> >
> > /* sizeof(*myarray)==sizeof(struct mystruct).
> > A 200x100 array on the free store is created */
> > myarray=malloc(200*sizeof(*myarray));
> >
> > /* Do something */
> >
> >
> > free(myarray);
> >
> > return 0;
> > }
>
> Can't be alternative 3, since it isn't a solution to the same probem.
> This also assumes that you at compile time know one of the dimensions. In
> C, you can't make this a template function, so you can't adjust the length
> of the myarray declaration.
> Let's go one step further. Let's assume I already know both dimensions:
> struct mystruct (*myarray)[200][300];
> myarray = malloc(sizeof(*myarray));
> >
> >
> >
> > Ioannis
> >
> > * Ioannis Vranos
> > * Programming pages: http://www.noicys.freeurl.com
> > * Alternative URL: http://run.to/noicys
> >
> >
> >
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by: Influence the future
> > of Java(TM) technology. Join the Java Community
> > Process(SM) (JCP(SM)) program now.
> > http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0003en
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
> http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0003en
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Per W. <pw...@ia...> - 2002-10-24 22:03:13
|
Amen brother :-) /Per W On Fri, 25 Oct 2002, Ioannis Vranos wrote: > > -----Original Message----- > > From: Per Westermark [mailto:pw...@ia...] > > Sent: Friday, October 25, 2002 12:12 AM > > To: Ioannis Vranos > > Cc: 'dev-cpp-users-list' > > Subject: RE: [Dev-C++] dynamic allocation and structs > > > > > > Answer is still yes. > > > > The question was: When will the memory be released. > > It will for just about all operating systems be released on > > termination > > of the program. If it wasn't, you would leak global memory in your > > computer, if you stop a program while debugging it, or if you manually > > kill the program. > > > > The destructor for all allocated objects will not be called, but that > > wasn't the question. The memory will be released! > > > The "No" was for: "Or when exiting the scope." (that probably somebody > else wrote). > > > Ioannis > > * Ioannis Vranos > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL: http://run.to/noicys > > > ------------------------------------------------------- > This sf.net email is sponsored by: Influence the future > of Java(TM) technology. Join the Java Community > Process(SM) (JCP(SM)) program now. > http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0003en > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Per W. <pw...@ia...> - 2002-10-24 22:02:19
|
Well Ioannis, I did manage to get a star on the wrong side of the struct
type name, see inserted correction below, so the example was slightly
broken. However, the example was not a total goose chase try at a
two-dimensional matrix of entries, but an example of creating a
one-dimensional matrix (a vector) of pointers to single entries, which was
exactly what the heading suggested "array of pointers to entries". If the
code wasn't obvious, a hint to that fact should have been that I only
used a single for loop to assign values to the entries.
One reason to use alternative two, a vector of pointers to elements
instead of a vector of elements, is that sorting of the vector only
require changing the place of the pointers, instead of copying the full
structures.
Another reason is that it might be used to create a sparse matrix, where
the vector might be very long, but only some index values of the vector
will have an allocated entry.
A third reason is that a vector of pointers might be to store different
types of structs in the same vector, as in:
enum {
CIRCLE,
LINE,
BOX
};
struct Circle {
int type;
int x,y;
int radius;
};
struct Line {
int type;
int x1,y1,x2,y2;
}
struct Box {
int type;
int x1,y1,x2,y2;
};
void fill_array() {
Circle *pCircle;
Line *pLine;
Box *pBox;
int item_count,i;
item_count = 0;
pCircle = (Circle*)malloc(sizeof(Circle));
pCircle->type = CIRCLE;
pCircle->x = 10;
pCircle->y = 20;
pCircle->radius = 5;
myarray[item_count++] = pCircle;
pBox = (Box*)malloc(sizeof(Box));
pBox->type = BOX;
pBox->x1 = 15;
pBox->y1 = 2;
pBox->x2 = 18;
pBox->y2 = 5;
myarray[item_count++] = pBox;
...
// Draw items.
for (i = 0; i < item_count; i++) {
if (myarray[i]) {
switch (myarray[i]->type) {
case CIRCLE:
pCircle = (Circle*)myarray[i];
// Draw circle
break;
case BOX:
pBox = (Box*)myarray[i];
// Draw box
break;
case LINE:
pLine = (Line*)myarray[i];
// Draw line
break;
default:
// Complain about unsupported object type.
}
}
}
By the way, to clean a vector of pointers to objects would require:
for (i = 0; i < count; i++)
free(myarray[i]); // Release individual elements
free(myarray); // Release array of pointers
/Per W
On Thu, 24 Oct 2002, Ioannis Vranos wrote:
> > -----Original Message-----
> > From: dev...@li...
> > [mailto:dev...@li...] On Behalf
> > Of Per Westermark
> > Sent: Thursday, October 24, 2002 4:13 PM
> > To: Scott Williams
> > Cc: dev...@li...
> > Subject: Re: [Dev-C++] dynamic allocation and structs
> >
> >
> >
> > // Alternative 1, array of entries.
> > mystruct *myarray;
> > void func(int count) {
> > int i;
> > myarray = (mystruct*)malloc(count*sizeof(mystruct));
> > for (i = 0; i < count; i++) {
> > myarray[i].xx = yy;
> > }
> > }
> >
> > // Alternative 2, array of pointers to entries.
> > mystruct **myarray;
> > void func(int count) {
> > int i;
> > myarray = (mystruct**)malloc(count*sizeof(*mystruct));
======> myarray = (mystruct**)malloc(count*sizeof(mystruct*));
> > for (i = 0; i < count; i++) {
> > myarray[i] = (mystruct*)malloc(sizeof(mystruct));
> > myarray[i]->xx = yy;
> > }
> > }
>
>
> The Alternative 2 is wrong. You use a ** pointer and then you assign
> values as if it is a *.
No, I use a ** pointer to assign an array of pointers.
Then I use a * pointer to assign an entry.
>
>
> A working example of what you are trying to do:
A working example of something I didn't tried to do :-)
>
> #include <stdlib.h>
> #include <stdio.h>
>
> int main()
> {
> struct mystruct
> {
> int x;
> };
>
> struct mystruct **myarray;
>
> int i, j;
>
> /* sizeof(*myarray)==sizeof(struct mystruct *) */
> myarray=malloc(100*sizeof(*myarray));
>
> /* sizeof(**myarray)==sizeof(struct mystruct).
> A 200x100 array on the free store is created */
> for(i=0; i<100; i++)
> myarray[i]=malloc(200*sizeof(**myarray));
>
> /* Do something */
> for(i=0; i<100; i++)
> for(j=0; j<200; j++)
> {
> myarray[i][j].x=i+j;
>
> printf("%d\n", myarray[i][j].x);
> }
>
>
> for(i=0; i<100; i++)
> free(myarray[i]);
>
> free(myarray);
>
> return 0;
> }
>
>
>
>
> Alternative 3 (which must be prefered if possible instead of A-2):
>
> #include <stdlib.h>
>
> int main()
> {
> struct mystruct
> {
> int x;
> };
>
> struct mystruct (*myarray)[100];
>
> /* sizeof(*myarray)==sizeof(struct mystruct).
> A 200x100 array on the free store is created */
> myarray=malloc(200*sizeof(*myarray));
>
> /* Do something */
>
>
> free(myarray);
>
> return 0;
> }
Can't be alternative 3, since it isn't a solution to the same probem.
This also assumes that you at compile time know one of the dimensions. In
C, you can't make this a template function, so you can't adjust the length
of the myarray declaration.
Let's go one step further. Let's assume I already know both dimensions:
struct mystruct (*myarray)[200][300];
myarray = malloc(sizeof(*myarray));
>
>
>
> Ioannis
>
> * Ioannis Vranos
> * Programming pages: http://www.noicys.freeurl.com
> * Alternative URL: http://run.to/noicys
>
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
> http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0003en
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: newsoft <ne...@so...> - 2002-10-24 21:54:52
|
Hello... I donwloaded and instaled the Dev C++ 4.9.6.0... and when I tray to run eny proyect ocurres one error and this message: 'all-before' does not exist - don't know to make it.... Luis. _________________________ "Satyât nâsti paro dharmah" _________________________ |
|
From: Ioannis V. <no...@ho...> - 2002-10-24 21:19:52
|
> -----Original Message----- > From: Per Westermark [mailto:pw...@ia...] > Sent: Friday, October 25, 2002 12:12 AM > To: Ioannis Vranos > Cc: 'dev-cpp-users-list' > Subject: RE: [Dev-C++] dynamic allocation and structs > > > Answer is still yes. > > The question was: When will the memory be released. > It will for just about all operating systems be released on > termination > of the program. If it wasn't, you would leak global memory in your > computer, if you stop a program while debugging it, or if you manually > kill the program. > > The destructor for all allocated objects will not be called, but that > wasn't the question. The memory will be released! The "No" was for: "Or when exiting the scope." (that probably somebody else wrote). Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL: http://run.to/noicys |
|
From: Per W. <pw...@ia...> - 2002-10-24 21:12:13
|
Answer is still yes. The question was: When will the memory be released. It will for just about all operating systems be released on termination of the program. If it wasn't, you would leak global memory in your computer, if you stop a program while debugging it, or if you manually kill the program. The destructor for all allocated objects will not be called, but that=20 wasn't the question. The memory will be released! /Per W On Thu, 24 Oct 2002, Ioannis Vranos wrote: > > -----Original Message----- > > From: dev...@li...=20 > > [mailto:dev...@li...] On Behalf=20 > > Of Carlos Garc=A6=CDa del Monte > > Sent: Thursday, October 24, 2002 5:26 PM > > To: dev-cpp-users-list > > Subject: Re: [Dev-C++] dynamic allocation and structs > >=20 > >=20 > >=20 > >=20 > > Per Westermark escribi=A8=AE: > >=20 > > > Well, maybe not directly forever. > > > > > > It will also be automatically released - for most operating=20 > > systems, that > > > is - when the application ends. > >=20 > > Or when exiting the scope. >=20 >=20 > No. >=20 >=20 > Ioannis >=20 > * Ioannis Vranos > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL: http://run.to/noicys >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This sf.net email is sponsored by: Influence the future > of Java(TM) technology. Join the Java Community > Process(SM) (JCP(SM)) program now. > http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0003en > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >=20 |
|
From: Ioannis V. <no...@ho...> - 2002-10-24 20:58:43
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of Carlos Garc=A6=CDa del Monte > Sent: Thursday, October 24, 2002 5:26 PM > To: dev-cpp-users-list > Subject: Re: [Dev-C++] dynamic allocation and structs >=20 >=20 >=20 >=20 > Per Westermark escribi=A8=AE: >=20 > > Well, maybe not directly forever. > > > > It will also be automatically released - for most operating=20 > systems, that > > is - when the application ends. >=20 > Or when exiting the scope. No. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL: http://run.to/noicys |
|
From: Ioannis V. <no...@ho...> - 2002-10-24 20:57:27
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Per Westermark
> Sent: Thursday, October 24, 2002 4:13 PM
> To: Scott Williams
> Cc: dev...@li...
> Subject: Re: [Dev-C++] dynamic allocation and structs
>
>
>
> // Alternative 1, array of entries.
> mystruct *myarray;
> void func(int count) {
> int i;
> myarray = (mystruct*)malloc(count*sizeof(mystruct));
> for (i = 0; i < count; i++) {
> myarray[i].xx = yy;
> }
> }
>
> // Alternative 2, array of pointers to entries.
> mystruct **myarray;
> void func(int count) {
> int i;
> myarray = (mystruct**)malloc(count*sizeof(*mystruct));
> for (i = 0; i < count; i++) {
> myarray[i] = (mystruct*)malloc(sizeof(mystruct));
> myarray[i]->xx = yy;
> }
> }
The Alternative 2 is wrong. You use a ** pointer and then you assign
values as if it is a *.
A working example of what you are trying to do:
#include <stdlib.h>
#include <stdio.h>
int main()
{
struct mystruct
{
int x;
};
struct mystruct **myarray;
int i, j;
/* sizeof(*myarray)==sizeof(struct mystruct *) */
myarray=malloc(100*sizeof(*myarray));
/* sizeof(**myarray)==sizeof(struct mystruct).
A 200x100 array on the free store is created */
for(i=0; i<100; i++)
myarray[i]=malloc(200*sizeof(**myarray));
/* Do something */
for(i=0; i<100; i++)
for(j=0; j<200; j++)
{
myarray[i][j].x=i+j;
printf("%d\n", myarray[i][j].x);
}
for(i=0; i<100; i++)
free(myarray[i]);
free(myarray);
return 0;
}
Alternative 3 (which must be prefered if possible instead of A-2):
#include <stdlib.h>
int main()
{
struct mystruct
{
int x;
};
struct mystruct (*myarray)[100];
/* sizeof(*myarray)==sizeof(struct mystruct).
A 200x100 array on the free store is created */
myarray=malloc(200*sizeof(*myarray));
/* Do something */
free(myarray);
return 0;
}
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|
|
From: Ioannis V. <no...@ho...> - 2002-10-24 20:29:23
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Scott Williams
> Sent: Thursday, October 24, 2002 3:18 PM
> To: dev...@li...
> Subject: [Dev-C++] dynamic allocation and structs
>=20
>=20
> Hi,
>=20
> I'm working in C (no C++ please). Got a couple of questions=20
> related to
> dynamic allocation and in particular, dynamically allocating=20
> an array of
> structs.
>=20
> First, what is the duration of memory allocated by malloc (etc.)? In
> particular, I want to dynamically allocate/de-allocate several global
> variables within a single subroutine called from main and so=20
> want to be sure
> that the allocated memory exists beyond the scope of that subroutine.
>=20
> Second, it is my understanding that it is perfectly=20
> acceptable to have an
> array of structs. E.g.,
>=20
> struct mystruct {
> double var1;
> long var2;
> etc...
> }
>=20
> . . .
>=20
> struct mystruct data[100];
>=20
> Is this correct? If so, what then is the calling sequence to=20
> dynamically
> allocate an array of structs, and, in particularly, make the result
> available globally?
>=20
> Thanks for your help (& sorry if this is naive).
Yes you can have an array of structs, either in automatic storage like
your example above, or on the free store. Objects on the free store
exist till you free() that memory while your program is running. If you
do not free() that memory and lose its address (in some point you have
no pointer pointing to it), then you have a memory leak.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|
|
From: <we...@ha...> - 2002-10-24 20:27:49
|
Hi, I'm trying do my program sleep from 25 to 40 min. I tryed use the funcion sleep() but i can't do it. :/ Someone know how to do it ?? Can gave-me a example ?? Thkz a lot. Best Regards. [ ]'s |
|
From: <XI...@pr...> - 2002-10-24 17:13:49
|
And that will fix the unsupported toolkit error in fonts.h? Cool. (PS-I did not see your response amongst the digests from that period...) --- Original Message --- From: dev...@li... To: dev...@li... Subject: Dev-cpp-users digest, Vol 1 #1071 - 9 msgs >Send Dev-cpp-users mailing list submissions to > dev...@li... > >To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/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: WxWINDOWS and Dev-C++ (Per Westermark) > 2. 4.9.6.5 bug (Carlos =3D?iso-8859-1?Q?Garc=3DEDa?=3D del Monte) > 3. Re: Input one file output another. (Daniel Glenfield) > 4. Re: drawing in Windows (Daniel Glenfield) > 5. Re: Whoops - drawing in Windows (Daniel Glenfield) > 6. RE : [Dev-C++] How to keep the DOS console open? (Pierre Lepage) > 7. Re: RE : [Dev-C++] How to keep the DOS console open? (Daniel Glenfi= >eld) > 8. Strange phenomenon (Christian Wallukat) > 9. Re: Whoops - drawing in Windows (Vlada Djurovic) > >--__--__-- > >Message: 1 >Date: Thu, 24 Oct 2002 11:36:49 +0200 (CEST) >From: Per Westermark <pw...@ia...> >Reply-To: Per Westermark <pw...@ia...> >To: David Scott Williams <xi...@pr...> >cc: dev...@li... >Subject: RE: [Dev-C++] WxWINDOWS and Dev-C++ > >Hello David! > >As a regular user of sourceforge, you should know that sourceforge keeps >the archive of this mailing list. You only have to scan two days back to >find your specific question, and an answer. > >/Per W > >On Mon, 21 Oct 2002, Per Westermark wrote: > >> The problem is that you have forgotten do define which compiler >> environment you are using. >>=3D20 >> Deefine __GNUWIN32__ and wxWindows will select a suitable string compar= >e >> function. >>=3D20 >> A good trick when playing along with the wxWindows kit is to run the >> makefiles in the samples directory. When they compile the code, you wil= >l >> see a number of parameters sent to gcc. If you make sure that your own >> projects uses the same parameters, you will be home-free. >>=3D20 >> You will get all needed libraries, same settings for run-time type >> information, debug settings etc. >>=3D20 >> /Per W >>=3D20 >> On Mon, 21 Oct 2002, Santiago Palmier Campos wrote: >>=3D20 >> > Hi Mark, >> >=3D20 >> > This error may appear due to... >> >=3D20 >> > ...uncomplete/wrong build of wxWindows libraries; so you have to rebu= >il=3D >d the >> > libraries correctly. >> >=3D20 >> > ...wrong order for include directories, please check them and take a = >lo=3D >ok >> > at: >> > http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Directory-Options.html#Dire= >ct=3D >ory%2 >> > 0Options >> > I think it is really useful sometimes ;o) >> >=3D20 >> > Hope this helps! >> > Regards >> >=3D20 >> > Santy >> > PS: wxWindows is not so hard/difficult to use, just be a little bit p= >at=3D >ient >> > at the beginning, follow the README instructions and take a look at s= >om=3D >e >> > tutorials, they are great!!! Just my 2 cents! >> >=3D20 >> > -----Original Message----- >> > From: Mark L. Wise [mailto:ma...@al...]=3D20 >> > Sent: s=3DE1bado, 19 de octubre de 2002 0:03 >> > To: dev...@li... >> > Subject: [Dev-C++] WxWINDOWS and Dev-C++ >> >=3D20 >> >=3D20 >> > Hello all! >> >=3D20 >> > Sorry to be such a pain regarding WxWINDOWS and Dev-C++, but.... >> >=3D20 >> > I have been trying to compile some of the sample code included with t= >he >> > WxWINDOWS package. When I try compiling I get the following message = >(a=3D >long >> > with other things...) >> >=3D20 >> > 4 C:\PROGRAM FILES\DEV-C++\include\wx\string.h:170 >> > #error "Please define string case-insensitive compare for your OS/com= >pi=3D >ler" >> >=3D20 >> > So... How do I define string case-insensitive compare in Dev-C++??? >> >=3D20 >> > Thanks in advance... >> >=3D20 >> > Mark >> >=3D20 >> > Alpha II Service, Inc. >> > 1312 Epworth Avenue >> > Reynoldsburg, Ohio 43068 >> > 614 868-5033 (Voice) >> > 617 812-5838 (Fax) >> >=3D20 >> >=3D20 >> >=3D20 >> >=3D20 >> > ------------------------------------------------------- >> > This sf.net email is sponsored by:ThinkGeek >> > Welcome to geek heaven. >> > http://thinkgeek.com/sf _____________________________________________= >__ >> > Dev-cpp-users mailing list >> > Dev...@li... >> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm >> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >> > ---------------------------------------------------------------------= >--=3D >--------------- >> > This message and any files transmitted with it are confidential and i= >nt=3D >ended solely=3D20 >> > for the use of the individual or entity to whom they are addressed. N= >o =3D >confidentiality=3D20 >> > or privilege is waived or lost by any wrong transmission.=3D20 >> > If you have received this message in error, please immediately destro= >y =3D >it and kindly=3D20 >> > notify the sender by reply email. >> > You must not, directly or indirectly, use, disclose, distribute, prin= >t,=3D > or copy any=3D20 >> > part of this message if you are not the intended recipient. Opinions,= > c=3D >onclusions and=3D20 >> > other information in this message that do not relate to the official = >bu=3D >siness of=3D20 >> > Ydilo Advanced Voice Solutions, S.A. shall be understood as neither g= >iv=3D >en nor endorsed by it.=3D20 >> > ---------------------------------------------------------------------= >--=3D >--------------- >> >=3D20 >> >=3D20 >> > ------------------------------------------------------- >> > This sf.net email is sponsored by:ThinkGeek >> > Welcome to geek heaven. >> > http://thinkgeek.com/sf >> > _______________________________________________ >> > Dev-cpp-users mailing list >> > Dev...@li... >> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm >> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >> >=3D20 >>=3D20 >>=3D20 > > > > >--__--__-- > >Message: 2 >Date: Thu, 24 Oct 2002 11:17:18 +0200 >From: Carlos =3D?iso-8859-1?Q?Garc=3DEDa?=3D del Monte <cg...@wo...> >To: dev-cpp-users-list <dev...@li...> >Subject: [Dev-C++] 4.9.6.5 bug > >I updated Dev to the 4.9.6.5 version, now the import MSVisual project >does not work, I select the dsp file and when I click on import button >it does nothing. > > > >--__--__-- > >Message: 3 >From: "Daniel Glenfield" <sp...@ho...> >To: Tam...@dl..., dev...@li... >Subject: Re: [Dev-C++] Input one file output another. >Date: Thu, 24 Oct 2002 10:43:30 +0100 > > >This constructor may help >fstream( const char* szName, int nMode, int nProt =3D filebuf::openprot )= >; > >szName is the name of the file, >nMode is ios::in, ios::out etc. >then use >filebuf::sh_read (Read sharing allowed.) >and >filebuf::sh_write (Write sharing allowed.) >with the || operator. > > >Try closing the file as well once you are done with it. > > >>From: "Mitchell, Tamra (DLM)" <Tam...@dl...> >>To: "'dev...@li...'"=20 >><dev...@li...> >>Subject: [Dev-C++] Input one file output another. >>Date: Wed, 23 Oct 2002 14:54:20 -0400 >> >> >>Rephrase question. >> >>I am trying read test from one file and output to another file and am no= >t >>sure how to complete correctly. >> >>#include<fstream> >>#include<iostream> >>using namespace std; >> >>void main(){ >> ifstream fin; >> ofstream fout; >> fin.open("Eb.txt"); >> /*if(fin=3D=3D0){ >> cout << " input file xx.txt not found "<< endl; >> }*/ >> fout.open("y.txt"); >> int a[10],i; >> for(i=3D0;i<10;i++) >> fin >> a[i]; >> for(i=3D0;i<10;i++) >> fout << a[i] << endl; >> >>} >> >> >>Can anyone offer any suggestions. >> >>Tamra Y. Mitchell >>Database & Operating Systems Analyst >>412-222-8203 - Work >>412-996-9078 - Cell >> > > >_________________________________________________________________ >Surf the Web without missing calls!=A0Get MSN Broadband. =20 >http://resourcecenter.msn.com/access/plans/freeactivation.asp > > > >--__--__-- > >Message: 4 >From: "Daniel Glenfield" <sp...@ho...> >To: dj...@im..., dev...@li... >Subject: Re: [Dev-C++] drawing in Windows >Date: Thu, 24 Oct 2002 10:45:02 +0100 > >Yes you need to serialise the information to a file. I'll see if I can di= >g=20 >up some information on this, but that's what you need to do. > > > > > > >>From: "Vlada Djurovic" <dj...@im...> >>To: "'DevC++ help'" <dev...@li...> >>Subject: [Dev-C++] drawing in Windows >>Date: Thu, 24 Oct 2002 10:32:16 +0200 >> >>Hi, everybody >>Here's my problem: I'm trying to write a simple drawing app (just for=20 >>exercise) and so far its been going OK. I can draw lines in client area = >in=20 >>different colors, but when ever I minimize or maximize the window, or=20 >>something similar happenes, all the content of the window is gone. I tri= >ed=20 >>to use a memory DC an bitmap to save the contents in, and BitBlt it back= > in=20 >>response to WM_PAINT message, but the program just "froze". Can anybody=20 >>give me a hint how to do it? Here's the code used for drawing lines with= >out=20 >>any restoring parts: >> >> case WM_MOUSEMOVE: >> { >> switch(iTool) /* iTool is used for dtetrmining wh= >ich=20 >>drawing tool is selected(line, rect etc.)*/ >> { >> case 0: >> { >> if(wParam=3D=3DMK_LBUTTON) /*if line is selected=20 >>(itool=3D0) and left button presed*/ >> { >> HDC hDC=3DGetDC(hwnd); >> >> HPEN hPen=3DCreatePen(PS_SOLID,iCurWidth,crCurCo= >lor); >> HPEN hOldPen=3D(HPEN)SelectObject(hDC,hPen); >> CLine* pLine=3Dnew=20 >>CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new l= >ine=20 >>object*/ >> pLine->DrawLine(hDC); >> ptPrevPos=3DMAKEPOINTS(lParam); >> SelectObject(hDC,hOldPen); >> DeleteDC(hDC); >> } >> } >> break; >> case 1: /* nothing here yet*/ >> break; >> } >> } > > >_________________________________________________________________ >Protect your PC - get McAfee.com VirusScan Online=20 >http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3D3963 > > > >--__--__-- > >Message: 5 >From: "Daniel Glenfield" <sp...@ho...> >To: dj...@im..., dev...@li... >Subject: Re: [Dev-C++] Whoops - drawing in Windows >Date: Thu, 24 Oct 2002 10:59:19 +0100 > >Nope maybe not, serialising is for saving and restoring. > >I think you have to store the info in to an array, but looking at this ol= >d=20 >code I cannot remember what exactly you have to do. I worked on the Scrib= >ble=20 >tutorial that comes with VC++ - have a look on MSDN for it. > > > >>From: "Vlada Djurovic" <dj...@im...> >>To: "'DevC++ help'" <dev...@li...> >>Subject: [Dev-C++] drawing in Windows >>Date: Thu, 24 Oct 2002 10:32:16 +0200 >> >>Hi, everybody >>Here's my problem: I'm trying to write a simple drawing app (just for=20 >>exercise) and so far its been going OK. I can draw lines in client area = >in=20 >>different colors, but when ever I minimize or maximize the window, or=20 >>something similar happenes, all the content of the window is gone. I tri= >ed=20 >>to use a memory DC an bitmap to save the contents in, and BitBlt it back= > in=20 >>response to WM_PAINT message, but the program just "froze". Can anybody=20 >>give me a hint how to do it? Here's the code used for drawing lines with= >out=20 >>any restoring parts: >> >> case WM_MOUSEMOVE: >> { >> switch(iTool) /* iTool is used for dtetrmining wh= >ich=20 >>drawing tool is selected(line, rect etc.)*/ >> { >> case 0: >> { >> if(wParam=3D=3DMK_LBUTTON) /*if line is selected=20 >>(itool=3D0) and left button presed*/ >> { >> HDC hDC=3DGetDC(hwnd); >> >> HPEN hPen=3DCreatePen(PS_SOLID,iCurWidth,crCurCo= >lor); >> HPEN hOldPen=3D(HPEN)SelectObject(hDC,hPen); >> CLine* pLine=3Dnew=20 >>CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new l= >ine=20 >>object*/ >> pLine->DrawLine(hDC); >> ptPrevPos=3DMAKEPOINTS(lParam); >> SelectObject(hDC,hOldPen); >> DeleteDC(hDC); >> } >> } >> break; >> case 1: /* nothing here yet*/ >> break; >> } >> } > > >_________________________________________________________________ >Get a speedy connection with MSN Broadband.=A0 Join now!=20 >http://resourcecenter.msn.com/access/plans/freeactivation.asp > > > >--__--__-- > >Message: 6 >Date: Thu, 24 Oct 2002 06:45:59 -0400 >From: Pierre Lepage <fam...@gl...> >Subject: RE : [Dev-C++] How to keep the DOS console open? >To: da...@ir... >Cc: dev...@li... > >C'est un message de format MIME en plusieurs parties. > >--Boundary_(ID_67V4hQiqD3A0FRmuYaAghQ) >Content-type: text/plain; charset=3Diso-8859-1 >Content-transfer-encoding: QUOTED-PRINTABLE > >You must send a command to DOS to pause for sometime. > >The solution look like this : > > >#include <cstdlib> // function system > > >=3D85 > >void main { > >=3D85 your programm > > system(=3D93PAUSE=3D94); > >} // end of main. > > >--Boundary_(ID_67V4hQiqD3A0FRmuYaAghQ) >Content-type: text/html; charset=3Diso-8859-1 >Content-transfer-encoding: QUOTED-PRINTABLE > ><html xmlns:o=3D3D"urn:schemas-microsoft-com:office:office" xmlns:w=3D >=3D3D"urn:schemas-microsoft-com:office:word" xmlns=3D3D"http://www.w3.org= >=3D >/TR/REC-html40"> > ><head> ><meta http-equiv=3D3DContent-Type content=3D3D"text/html; charset=3D3Diso= >-8=3D >859-1"> ><meta name=3D3DProgId content=3D3DWord.Document> ><meta name=3D3DGenerator content=3D3D"Microsoft Word 9"> ><meta name=3D3DOriginator content=3D3D"Microsoft Word 9"> ><link rel=3D3DFile-List href=3D3D"cid:filelist.xml@01C27B28.FCB62920"> ><!--[if gte mso 9]><xml> > <o:OfficeDocumentSettings> > <o:DoNotRelyOnCSS/> > </o:OfficeDocumentSettings> ></xml><![endif]--><!--[if gte mso 9]><xml> > <w:WordDocument> > <w:View>Normal</w:View> > <w:Zoom>0</w:Zoom> > <w:DocumentKind>DocumentEmail</w:DocumentKind> > <w:HyphenationZone>21</w:HyphenationZone> > <w:EnvelopeVis/> > <w:DrawingGridHorizontalSpacing>5 pt</w:DrawingGridHorizontalSpacin=3D >g> > <w:DrawingGridVerticalSpacing>8.15 pt</w:DrawingGridVerticalSpacing=3D >> > <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingG=3D >ridEvery> > <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridE=3D >very> > <w:Compatibility> > <w:FootnoteLayoutLikeWW8/> > <w:ShapeLayoutLikeWW8/> > <w:AlignTablesRowByRow/> > <w:ForgetLastTabAlignment/> > <w:DoNotUseHTMLParagraphAutoSpacing/> > <w:LayoutRawTableWidth/> > <w:LayoutTableRowsApart/> > </w:Compatibility> > </w:WordDocument> ></xml><![endif]--> ><style> ><!-- > /* Style Definitions */ >p.MsoNormal, li.MsoNormal, div.MsoNormal >=3D09{mso-style-parent:""; >=3D09margin:0in; >=3D09margin-bottom:.0001pt; >=3D09mso-pagination:widow-orphan; >=3D09font-size:10.0pt; >=3D09font-family:"Times New Roman"; >=3D09mso-fareast-font-family:"Times New Roman";} >p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig >=3D09{margin:0in; >=3D09margin-bottom:.0001pt; >=3D09mso-pagination:widow-orphan; >=3D09font-size:10.0pt; >=3D09font-family:"Times New Roman"; >=3D09mso-fareast-font-family:"Times New Roman";} >span.StyleCourrierlectronique15 >=3D09{mso-style-type:personal-compose; >=3D09mso-ansi-font-size:10.0pt; >=3D09mso-ascii-font-family:Arial; >=3D09mso-hansi-font-family:Arial; >=3D09mso-bidi-font-family:Arial; >=3D09color:black;} >@page Section1 >=3D09{size:595.25pt 841.85pt; >=3D09margin:56.7pt 56.7pt 56.7pt 56.7pt; >=3D09mso-header-margin:.5in; >=3D09mso-footer-margin:.5in; >=3D09mso-paper-source:0;} >div.Section1 >=3D09{page:Section1;} >--> ></style> ></head> > ><body lang=3D3DFR-CA style=3D3D'tab-interval:35.4pt'> > ><div class=3D3DSection1> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'>You must send a command to DOS to paus=3D >e for >sometime.<o:p></o:p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'><![if !supportEmptyParas]> <![end=3D >if]><o:p></o:p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'>The solution look like this :<o:p></o:=3D >p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'><![if !supportEmptyParas]> <![end=3D >if]><o:p></o:p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'><![if !supportEmptyParas]> <![end=3D >if]><o:p></o:p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'>#include <cstdlib><span >style=3D3D"mso-spacerun: yes"> </span>// function system<o:p></o:=3D >p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'><![if !supportEmptyParas]> <![end=3D >if]><o:p></o:p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'><![if !supportEmptyParas]> <![end=3D >if]><o:p></o:p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'>…<o:p></o:p></span></font></span=3D >></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'><![if !supportEmptyParas]> <![end=3D >if]><o:p></o:p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'>void main {<o:p></o:p></span></font></=3D >span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'><![if !supportEmptyParas]> <![end=3D >if]><o:p></o:p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'>… your programm<o:p></o:p></span=3D >></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'><![if !supportEmptyParas]> <![end=3D >if]><o:p></o:p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'><span style=3D3D"mso-spacerun: >yes"> </span>system(“PAUSE”);<o:p></o:p></span></fon=3D >t></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'><![if !supportEmptyParas]> <![end=3D >if]><o:p></o:p></span></font></span></p> > ><p class=3D3DMsoNormal><span class=3D3DStyleCourrierlectronique15><font s= >=3D >ize=3D3D2 >color=3D3Dblack face=3D3DArial><span lang=3D3DEN-CA style=3D3D'font-size:= >10.0=3D >pt;font-family: >Arial;mso-ansi-language:EN-CA'>} // end of main.<o:p></o:p></span></f=3D >ont></span></p> > ></div> > ></body> > ></html> > > >--Boundary_(ID_67V4hQiqD3A0FRmuYaAghQ)-- > > >--__--__-- > >Message: 7 >From: "Daniel Glenfield" <sp...@ho...> >To: dev...@li... >Subject: Re: RE : [Dev-C++] How to keep the DOS console open? >Date: Thu, 24 Oct 2002 12:19:45 +0100 > >lol hasn't this been asked almost as much as the "how do I unsubscribe"=20 >question? Maybe Ioannis can put a page on his website to detail the=20 >different methods? > > > >>From: Pierre Lepage <fam...@gl...> >>To: da...@ir... >>CC: dev...@li... >>Subject: RE : [Dev-C++] How to keep the DOS console open? >>Date: Thu, 24 Oct 2002 06:45:59 -0400 >> >>You must send a command to DOS to pause for sometime. >> >>The solution look like this : >> >> >>#include <cstdlib> // function system >> >> >>=85 >> >>void main { >> >>=85 your programm >> >> system(=93PAUSE=94); >> >>} // end of main. >> > > >_________________________________________________________________ >Protect your PC - get McAfee.com VirusScan Online=20 >http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3D3963 > > > >--__--__-- > >Message: 8 >From: Christian Wallukat <Chr...@vo...> >To: "Dev-Cpp-Users@Lists. Sourceforge. Net (E-Mail)" > <dev...@li...> >Date: Thu, 24 Oct 2002 13:51:23 +0200 >Subject: [Dev-C++] Strange phenomenon > >Hi List, > > >i have a strange phenomenon in my project: > >I call a function: Test(char szTest[1024]) with Test("test"); > >In that function another Function (like the first) will be called: >Test2(szTest); > >the adress of szZest is 0x000000000.... > >and the content is empty .... > > >Anyone an Idea ???? > >Kind r > >Chris > > >--__--__-- > >Message: 9 >From: "Vlada Djurovic" <dj...@im...> >To: "Daniel Glenfield" <sp...@ho...>, > <dev...@li...> >Subject: Re: [Dev-C++] Whoops - drawing in Windows >Date: Thu, 24 Oct 2002 14:02:32 +0200 > > >----- Original Message ----- >From: "Daniel Glenfield" <sp...@ho...> >To: <dj...@im...>; <dev...@li...> >Sent: Thursday, October 24, 2002 11:59 AM >Subject: Re: [Dev-C++] Whoops - drawing in Windows > > >> Nope maybe not, serialising is for saving and restoring. >> >> I think you have to store the info in to an array, but looking at this = >old >> code I cannot remember what exactly you have to do. I worked on the >Scribble >> tutorial that comes with VC++ - have a look on MSDN for it. >> >> >I tried to store all the info in a linked list, but I think I did somethi= >ng >wrong because the program just froze when I tried to draw something. Then= > I >thought it would be easier to store the drawing in a compatible memory >bitmap and then just copy it back in the client area when it needs to be >redrawn, but this also didn't work because the program froze again. That'= >s >why I was asking if anyone can give me some guidelines about how to do th= >is >(the bitmap way). >As for the tutorials, I read the book "Teach yourself VC++ in 21 days" wh= >ich >also has some stuff about this, but although I think I did everything the >way it's done in VC++- it doesn't work. > >Regards, Vlada >> >> >From: "Vlada Djurovic" <dj...@im...> >> >To: "'DevC++ help'" <dev...@li...> >> >Subject: [Dev-C++] drawing in Windows >> >Date: Thu, 24 Oct 2002 10:32:16 +0200 >> > >> >Hi, everybody >> >Here's my problem: I'm trying to write a simple drawing app (just for >> >exercise) and so far its been going OK. I can draw lines in client are= >a >in >> >different colors, but when ever I minimize or maximize the window, or >> >something similar happenes, all the content of the window is gone. I >tried >> >to use a memory DC an bitmap to save the contents in, and BitBlt it ba= >ck >in >> >response to WM_PAINT message, but the program just "froze". Can anybod= >y >> >give me a hint how to do it? Here's the code used for drawing lines >without >> >any restoring parts: >> > >> > case WM_MOUSEMOVE: >> > { >> > switch(iTool) /* iTool is used for dtetrmining >which >> >drawing tool is selected(line, rect etc.)*/ >> > { >> > case 0: >> > { >> > if(wParam=3D=3DMK_LBUTTON) /*if line is selecte= >d >> >(itool=3D0) and left button presed*/ >> > { >> > HDC hDC=3DGetDC(hwnd); >> > >> > HPEN >hPen=3DCreatePen(PS_SOLID,iCurWidth,crCurColor); >> > HPEN hOldPen=3D(HPEN)SelectObject(hDC,hPen); >> > CLine* pLine=3Dnew >> >CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new >line >> >object*/ >> > pLine->DrawLine(hDC); >> > ptPrevPos=3DMAKEPOINTS(lParam); >> > SelectObject(hDC,hOldPen); >> > DeleteDC(hDC); >> > } >> > } >> > break; >> > case 1: /* nothing here yet*/ >> > break; >> > } >> > } >> >> >> _________________________________________________________________ >> Get a speedy connection with MSN Broadband. Join now! >> http://resourcecenter.msn.com/access/plans/freeactivation.asp >> > > > > >--__--__-- > >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > >End of Dev-cpp-users Digest ~Dave ||* Projects, active *|| Dustyscript (children programming): >http://dustyscript.sourceforge.net/< xTable: http://cxtable.sourceforge.net/ Grapevine: http://grapevineproject.org/ |
|
From: newsoft <ne...@so...> - 2002-10-24 16:02:04
|
Hello..=0D =0D Yes.. I want to know what set of cursors the user has selected for the Windows environment.. =0D =0D I need to change the set of cursors the user has selected for the Windows enviroment, but before change them I need keep the ones who was in used t= o restore them later....=0D =0D thank you=0D =0D Luis.=0D _________________________=0D "Saty=E2t n=E2sti paro dharmah"=0D _________________________=0D =0D -------Mensaje original-------=0D =0D De: Per Westermark=0D Fecha: jueves, 24 de octubre de 2002 10:18:55=0D A: newsoft=0D CC: dev-cpp-users=0D Asunto: Re: [Dev-C++] Who can I Know which cursor are defined in Windows since my application?.=0D =0D I'm not sure I understand the question.=0D =0D Do you want to know what type of cursor a specific window in your=0D application are using - arrow, cross, I-bar etc. Or do you want to know=0D what set of cursors the user has selected for the Windows environment,=0D i.e. small, large, animated etc?=0D =0D /Per W=0D =0D On Thu, 24 Oct 2002, newsoft wrote:=0D =0D > =0D > Hello everyone=0D > =0D > I'm new here, I hope to learn a few wiht all of yuo.... and here is my firts=0D > question!!!=0D > =0D > Who can I Know which cursor are defined in Windows since my application= ?.=0D > =0D > Sorry for my Eglish!!=0D > =0D > Luis.=0D > _________________________=0D > "Saty=E2t n=E2sti paro dharmah"=0D > _________________________=0D > =0D > =0D > =0D > -------------------------------------------------------=0D > This sf.net email is sponsored by: Influence the future=0D > of Java(TM) technology. Join the Java Community=0D > Process(SM) (JCP(SM)) program now.=0D > http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun com/javavote=0D > _______________________________________________=0D > Dev-cpp-users mailing list=0D > Dev...@li...=0D > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm=0D > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users=0D > =0D =0D =0D =2E |
|
From: Per W. <pw...@ia...> - 2002-10-24 14:46:38
|
Nope! Dyanmically allocated memory doesn't get released just because you leave the scope. An object destructor will - if correctly written - release memory allocted within the object, when the object goes out of scope. However, normal pointers doesn't have any destructors, so there will be no release of the memory. It will be the normal memory leak, i.e. a pointer no longer possible to access, that will not be released until the program ends, since unextended C++ doesn't have garbage collection. The only ways to release dynamically allocated memory is to: - manually releasing it - ending the program A destructor releasing local data from an object must be considered a =20 manual release, since the code specifically has to write a call to free() or delete. Yes, template-based containers can automatically release memory for the objects in the container, but only if the container destructor is called. If the container was created dynamically, the container will never get out of scope, so the destroctor won't run unless container is manually released... It is possible to create "smart pointers", i.e. a c++ object that looks and behaves like a pointer, but has a destructor that will release the memory when the "smart pointer" goes out of scope. Still, same thing as with template-based containers. If the "smart pointer" object is created dynamically, it won't go out of scope, and the destructor won't be called. /Per W EMA System email: pw...@ia... Per Westermark web: http://iapetus.neab.net Vargvaegen 174B phone: +46 8 410 17 198 S-906 42 Umeaa Sweden On Thu, 24 Oct 2002, Carlos Garc=EDa del Monte wrote: >=20 >=20 > Per Westermark escribi=F3: >=20 > > Well, maybe not directly forever. > > > > It will also be automatically released - for most operating systems, th= at > > is - when the application ends. >=20 > Or when exiting the scope. >=20 > > > > > > /Per W > > > > On Thu, 24 Oct 2002, Daniel Glenfield wrote: > > > > > I can help with the first - the lifetime of a variable created with m= alloc() > > > is forever - until you call free() of course! > > > > > > > > > > > > > > > >From: "Scott Williams" <se...@al...> > > > >Reply-To: <se...@al...> > > > >To: <dev...@li...> > > > >Subject: [Dev-C++] dynamic allocation and structs > > > >Date: Thu, 24 Oct 2002 08:18:24 -0400 > > > > > > > >Hi, > > > > > > > >I'm working in C (no C++ please). Got a couple of questions related= to > > > >dynamic allocation and in particular, dynamically allocating an arra= y of > > > >structs. > > > > > > > >First, what is the duration of memory allocated by malloc (etc.)? I= n > > > >particular, I want to dynamically allocate/de-allocate several globa= l > > > >variables within a single subroutine called from main and so want to= be > > > >sure > > > >that the allocated memory exists beyond the scope of that subroutine= =2E > > > > > > > >Second, it is my understanding that it is perfectly acceptable to ha= ve an > > > >array of structs. E.g., > > > > > > > >struct mystruct { > > > > double var1; > > > > long var2; > > > > etc... > > > >} > > > > > > > >. . . > > > > > > > >struct mystruct data[100]; > > > > > > > >Is this correct? If so, what then is the calling sequence to dynami= cally > > > >allocate an array of structs, and, in particularly, make the result > > > >available globally? > > > > > > > >Thanks for your help (& sorry if this is naive). > > > > > > > >Scott Williams > > > > > > > > > > > > > > > >------------------------------------------------------- > > > >This sf.net email is sponsored by: Influence the future > > > >of Java(TM) technology. Join the Java Community > > > >Process(SM) (JCP(SM)) program now. > > > >http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/j= avavote > > > >_______________________________________________ > > > >Dev-cpp-users mailing list > > > >Dev...@li... > > > >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > > > >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > _________________________________________________________________ > > > Surf the Web without missing calls! Get MSN Broadband. > > > http://resourcecenter.msn.com/access/plans/freeactivation.asp > > > > > > > > > > > > ------------------------------------------------------- > > > This sf.net email is sponsored by: Influence the future > > > of Java(TM) technology. Join the Java Community > > > Process(SM) (JCP(SM)) program now. > > > http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/ja= vavote > > > _______________________________________________ > > > Dev-cpp-users mailing list > > > Dev...@li... > > > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > ------------------------------------------------------- > > This sf.net email is sponsored by: Influence the future > > of Java(TM) technology. Join the Java Community > > Process(SM) (JCP(SM)) program now. > > http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/java= vote > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >=20 >=20 >=20 > ------------------------------------------------------- > This sf.net email is sponsored by: Influence the future > of Java(TM) technology. Join the Java Community > Process(SM) (JCP(SM)) program now. > http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavo= te > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >=20 |
|
From: <st...@nu...> - 2002-10-24 14:43:11
|
Hey guys! I've just released my latest game, KartingRace! You can find it at http://www.steinware.dk/opengl_kartingrace.php Let me know what ya think! ;) regards Stein Nygård - http://steinware.dk [The only normal people are the ones you don't know very well] |
|
From: Per W. <pw...@ia...> - 2002-10-24 14:35:26
|
Try to read the documentation about MySQL: http://www.mysql.com/documentation/mysql/bychapter/manual_Clients.html#mysql_connect Then, there are a number of good mailing lists specifically dedicated to MySQL: http://www.mysql.com/documentation/lists.html /Per W On Thu, 24 Oct 2002, Cidar F. Rojas Santamaria wrote: > How can I do direct connections with mySQL. > PLease help me. > > > > ------------------------------------------------------- > This sf.net email is sponsored by: Influence the future > of Java(TM) technology. Join the Java Community > Process(SM) (JCP(SM)) program now. > http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Carlos d. M. <cg...@wo...> - 2002-10-24 14:27:52
|
Per Westermark escribi=F3:
> Well, maybe not directly forever.
>
> It will also be automatically released - for most operating systems, th=
at
> is - when the application ends.
Or when exiting the scope.
>
>
> /Per W
>
> On Thu, 24 Oct 2002, Daniel Glenfield wrote:
>
> > I can help with the first - the lifetime of a variable created with m=
alloc()
> > is forever - until you call free() of course!
> >
> >
> >
> >
> > >From: "Scott Williams" <se...@al...>
> > >Reply-To: <se...@al...>
> > >To: <dev...@li...>
> > >Subject: [Dev-C++] dynamic allocation and structs
> > >Date: Thu, 24 Oct 2002 08:18:24 -0400
> > >
> > >Hi,
> > >
> > >I'm working in C (no C++ please). Got a couple of questions related=
to
> > >dynamic allocation and in particular, dynamically allocating an arra=
y of
> > >structs.
> > >
> > >First, what is the duration of memory allocated by malloc (etc.)? I=
n
> > >particular, I want to dynamically allocate/de-allocate several globa=
l
> > >variables within a single subroutine called from main and so want to=
be
> > >sure
> > >that the allocated memory exists beyond the scope of that subroutine=
=2E
> > >
> > >Second, it is my understanding that it is perfectly acceptable to ha=
ve an
> > >array of structs. E.g.,
> > >
> > >struct mystruct {
> > > double var1;
> > > long var2;
> > > etc...
> > >}
> > >
> > >. . .
> > >
> > >struct mystruct data[100];
> > >
> > >Is this correct? If so, what then is the calling sequence to dynami=
cally
> > >allocate an array of structs, and, in particularly, make the result
> > >available globally?
> > >
> > >Thanks for your help (& sorry if this is naive).
> > >
> > >Scott Williams
> > >
> > >
> > >
> > >-------------------------------------------------------
> > >This sf.net email is sponsored by: Influence the future
> > >of Java(TM) technology. Join the Java Community
> > >Process(SM) (JCP(SM)) program now.
> > >http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/j=
avavote
> > >_______________________________________________
> > >Dev-cpp-users mailing list
> > >Dev...@li...
> > >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> > >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
> >
> > _________________________________________________________________
> > Surf the Web without missing calls! Get MSN Broadband.
> > http://resourcecenter.msn.com/access/plans/freeactivation.asp
> >
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by: Influence the future
> > of Java(TM) technology. Join the Java Community
> > Process(SM) (JCP(SM)) program now.
> > http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/ja=
vavote
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
> http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/java=
vote
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Carlos d. M. <cg...@wo...> - 2002-10-24 14:23:52
|
You can create a DC where you select a bitmap, you draw in that bitmap an=
d you
BitBlt to the window each time you need it: when sizing and restoring, wh=
en you
draw something...
Daniel Glenfield escribi=F3:
> Nope maybe not, serialising is for saving and restoring.
>
> I think you have to store the info in to an array, but looking at this =
old
> code I cannot remember what exactly you have to do. I worked on the Scr=
ibble
> tutorial that comes with VC++ - have a look on MSDN for it.
>
> >From: "Vlada Djurovic" <dj...@im...>
> >To: "'DevC++ help'" <dev...@li...>
> >Subject: [Dev-C++] drawing in Windows
> >Date: Thu, 24 Oct 2002 10:32:16 +0200
> >
> >Hi, everybody
> >Here's my problem: I'm trying to write a simple drawing app (just for
> >exercise) and so far its been going OK. I can draw lines in client are=
a in
> >different colors, but when ever I minimize or maximize the window, or
> >something similar happenes, all the content of the window is gone. I t=
ried
> >to use a memory DC an bitmap to save the contents in, and BitBlt it ba=
ck in
> >response to WM_PAINT message, but the program just "froze". Can anybod=
y
> >give me a hint how to do it? Here's the code used for drawing lines wi=
thout
> >any restoring parts:
> >
> > case WM_MOUSEMOVE:
> > {
> > switch(iTool) /* iTool is used for dtetrmining =
which
> >drawing tool is selected(line, rect etc.)*/
> > {
> > case 0:
> > {
> > if(wParam=3D=3DMK_LBUTTON) /*if line is selecte=
d
> >(itool=3D0) and left button presed*/
> > {
> > HDC hDC=3DGetDC(hwnd);
> >
> > HPEN hPen=3DCreatePen(PS_SOLID,iCurWidth,crCur=
Color);
> > HPEN hOldPen=3D(HPEN)SelectObject(hDC,hPen);
> > CLine* pLine=3Dnew
> >CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new=
line
> >object*/
> > pLine->DrawLine(hDC);
> > ptPrevPos=3DMAKEPOINTS(lParam);
> > SelectObject(hDC,hOldPen);
> > DeleteDC(hDC);
> > }
> > }
> > break;
> > case 1: /* nothing here yet*/
> > break;
> > }
> > }
>
> _________________________________________________________________
> Get a speedy connection with MSN Broadband. Join now!
> http://resourcecenter.msn.com/access/plans/freeactivation.asp
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
> http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/java=
vote
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Per W. <pw...@ia...> - 2002-10-24 14:21:34
|
I'm not sure I understand the question. Do you want to know what type of cursor a specific window in your application are using - arrow, cross, I-bar etc. Or do you want to know what set of cursors the user has selected for the Windows environment, i.e. small, large, animated etc? /Per W On Thu, 24 Oct 2002, newsoft wrote: >=20 > Hello everyone >=20 > I'm new here, I hope to learn a few wiht all of yuo.... and here is my fi= rts > question!!! >=20 > Who can I Know which cursor are defined in Windows since my application?. >=20 > Sorry for my Eglish!! >=20 > Luis. > _________________________ > "Saty=E2t n=E2sti paro dharmah" > _________________________ >=20 >=20 >=20 > ------------------------------------------------------- > This sf.net email is sponsored by: Influence the future > of Java(TM) technology. Join the Java Community > Process(SM) (JCP(SM)) program now. > http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavo= te > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >=20 |
|
From: newsoft <ne...@so...> - 2002-10-24 14:14:32
|
Hello everyone I'm new here, I hope to learn a few wiht all of yuo.... and here is my firts question!!! Who can I Know which cursor are defined in Windows since my application?. Sorry for my Eglish!! Luis. _________________________ "Satyât nâsti paro dharmah" _________________________ |
|
From: Cidar F. R. S. <ci...@gm...> - 2002-10-24 14:01:43
|
How can I do direct connections with mySQL. PLease help me. |
|
From: Per W. <pw...@ia...> - 2002-10-24 13:34:09
|
There isn't a right or wrong between lists or bitmaps. The question is
what problems to solve.
Just fix repaint of window:
Simple bitmap will make perfect redraw in constant time, using constant
amount of memory.
Support undo, rescaling etc:
If all paint operations are stored in a list (or vector, ...) it the
amount of needed memory and needed redraw time will increase with the
complexity of the drawing. However, the additional bonus is easy support
for undo - just remove last entry from the list and redraw. Also, if all
coordinates are stored as a percentage of the window size, it is possible
to resize the window, and at repaint getting the image stretched
correspondingly, without any strange jaggies introduced by the resize of a
bitmap.
/Per W
On Thu, 24 Oct 2002, Daniel Glenfield wrote:
> I'm sure the linked list is the right way to do it, I just can't remember
> the specifics.
>
>
>
>
>
>
> >From: "Vlada Djurovic" <dj...@im...>
> >To: "Daniel Glenfield"
> ><sp...@ho...>,<dev...@li...>
> >Subject: Re: [Dev-C++] Whoops - drawing in Windows
> >Date: Thu, 24 Oct 2002 14:02:32 +0200
> >
> >
> >----- Original Message -----
> >From: "Daniel Glenfield" <sp...@ho...>
> >To: <dj...@im...>; <dev...@li...>
> >Sent: Thursday, October 24, 2002 11:59 AM
> >Subject: Re: [Dev-C++] Whoops - drawing in Windows
> >
> >
> > > Nope maybe not, serialising is for saving and restoring.
> > >
> > > I think you have to store the info in to an array, but looking at this
> >old
> > > code I cannot remember what exactly you have to do. I worked on the
> >Scribble
> > > tutorial that comes with VC++ - have a look on MSDN for it.
> > >
> > >
> >I tried to store all the info in a linked list, but I think I did something
> >wrong because the program just froze when I tried to draw something. Then I
> >thought it would be easier to store the drawing in a compatible memory
> >bitmap and then just copy it back in the client area when it needs to be
> >redrawn, but this also didn't work because the program froze again. That's
> >why I was asking if anyone can give me some guidelines about how to do this
> >(the bitmap way).
> >As for the tutorials, I read the book "Teach yourself VC++ in 21 days"
> >which
> >also has some stuff about this, but although I think I did everything the
> >way it's done in VC++- it doesn't work.
> >
> >Regards, Vlada
> > >
> > > >From: "Vlada Djurovic" <dj...@im...>
> > > >To: "'DevC++ help'" <dev...@li...>
> > > >Subject: [Dev-C++] drawing in Windows
> > > >Date: Thu, 24 Oct 2002 10:32:16 +0200
> > > >
> > > >Hi, everybody
> > > >Here's my problem: I'm trying to write a simple drawing app (just for
> > > >exercise) and so far its been going OK. I can draw lines in client area
> >in
> > > >different colors, but when ever I minimize or maximize the window, or
> > > >something similar happenes, all the content of the window is gone. I
> >tried
> > > >to use a memory DC an bitmap to save the contents in, and BitBlt it
> >back
> >in
> > > >response to WM_PAINT message, but the program just "froze". Can anybody
> > > >give me a hint how to do it? Here's the code used for drawing lines
> >without
> > > >any restoring parts:
> > > >
> > > > case WM_MOUSEMOVE:
> > > > {
> > > > switch(iTool) /* iTool is used for dtetrmining
> >which
> > > >drawing tool is selected(line, rect etc.)*/
> > > > {
> > > > case 0:
> > > > {
> > > > if(wParam==MK_LBUTTON) /*if line is selected
> > > >(itool=0) and left button presed*/
> > > > {
> > > > HDC hDC=GetDC(hwnd);
> > > >
> > > > HPEN
> >hPen=CreatePen(PS_SOLID,iCurWidth,crCurColor);
> > > > HPEN hOldPen=(HPEN)SelectObject(hDC,hPen);
> > > > CLine* pLine=new
> > > >CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new
> >line
> > > >object*/
> > > > pLine->DrawLine(hDC);
> > > > ptPrevPos=MAKEPOINTS(lParam);
> > > > SelectObject(hDC,hOldPen);
> > > > DeleteDC(hDC);
> > > > }
> > > > }
> > > > break;
> > > > case 1: /* nothing here yet*/
> > > > break;
> > > > }
> > > > }
> > >
> > >
> > > _________________________________________________________________
> > > Get a speedy connection with MSN Broadband. Join now!
> > > http://resourcecenter.msn.com/access/plans/freeactivation.asp
> > >
> >
> >
> >
> >-------------------------------------------------------
> >This sf.net email is sponsored by: Influence the future
> >of Java(TM) technology. Join the Java Community
> >Process(SM) (JCP(SM)) program now.
> >http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
> _________________________________________________________________
> Internet access plans that fit your lifestyle -- join MSN.
> http://resourcecenter.msn.com/access/plans/default.asp
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
> http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Per W. <pw...@ia...> - 2002-10-24 13:19:59
|
One question: Aren't you creating a lot of pens in your drawing loop.
Every time the mouse is moved, you create a new pen, with the same
specification as the pen you crated at your previous mouse move.
Exactly where are the "consumed" pens supposed to be released? At least in
Win32, you only have a finite set of available resource handles, so it
isn't possible to create new pens all the time. The task manager in Win2k
or WinXP may be configured to display number of handles used in the
application. That number shouldn't continuously increase when the program
is run.
Leaking pens, brushes, ... is a quick way of getting a program into
troubles - a lot more quickly than if the program leaks memory. There is
no swapping for resources.
/Per W
On Thu, 24 Oct 2002, Vlada Djurovic wrote:
>
> ----- Original Message -----
> From: "Daniel Glenfield" <sp...@ho...>
> To: <dj...@im...>; <dev...@li...>
> Sent: Thursday, October 24, 2002 11:59 AM
> Subject: Re: [Dev-C++] Whoops - drawing in Windows
>
>
> > Nope maybe not, serialising is for saving and restoring.
> >
> > I think you have to store the info in to an array, but looking at this old
> > code I cannot remember what exactly you have to do. I worked on the
> Scribble
> > tutorial that comes with VC++ - have a look on MSDN for it.
> >
> >
> I tried to store all the info in a linked list, but I think I did something
> wrong because the program just froze when I tried to draw something. Then I
> thought it would be easier to store the drawing in a compatible memory
> bitmap and then just copy it back in the client area when it needs to be
> redrawn, but this also didn't work because the program froze again. That's
> why I was asking if anyone can give me some guidelines about how to do this
> (the bitmap way).
> As for the tutorials, I read the book "Teach yourself VC++ in 21 days" which
> also has some stuff about this, but although I think I did everything the
> way it's done in VC++- it doesn't work.
>
> Regards, Vlada
> >
> > >From: "Vlada Djurovic" <dj...@im...>
> > >To: "'DevC++ help'" <dev...@li...>
> > >Subject: [Dev-C++] drawing in Windows
> > >Date: Thu, 24 Oct 2002 10:32:16 +0200
> > >
> > >Hi, everybody
> > >Here's my problem: I'm trying to write a simple drawing app (just for
> > >exercise) and so far its been going OK. I can draw lines in client area
> in
> > >different colors, but when ever I minimize or maximize the window, or
> > >something similar happenes, all the content of the window is gone. I
> tried
> > >to use a memory DC an bitmap to save the contents in, and BitBlt it back
> in
> > >response to WM_PAINT message, but the program just "froze". Can anybody
> > >give me a hint how to do it? Here's the code used for drawing lines
> without
> > >any restoring parts:
> > >
> > > case WM_MOUSEMOVE:
> > > {
> > > switch(iTool) /* iTool is used for dtetrmining
> which
> > >drawing tool is selected(line, rect etc.)*/
> > > {
> > > case 0:
> > > {
> > > if(wParam==MK_LBUTTON) /*if line is selected
> > >(itool=0) and left button presed*/
> > > {
> > > HDC hDC=GetDC(hwnd);
> > >
> > > HPEN
> hPen=CreatePen(PS_SOLID,iCurWidth,crCurColor);
> > > HPEN hOldPen=(HPEN)SelectObject(hDC,hPen);
> > > CLine* pLine=new
> > >CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new
> line
> > >object*/
> > > pLine->DrawLine(hDC);
> > > ptPrevPos=MAKEPOINTS(lParam);
> > > SelectObject(hDC,hOldPen);
> > > DeleteDC(hDC);
> > > }
> > > }
> > > break;
> > > case 1: /* nothing here yet*/
> > > break;
> > > }
> > > }
> >
> >
> > _________________________________________________________________
> > Get a speedy connection with MSN Broadband. Join now!
> > http://resourcecenter.msn.com/access/plans/freeactivation.asp
> >
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
> http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Per W. <pw...@ia...> - 2002-10-24 13:12:52
|
// Alternative 1, array of entries.
mystruct *myarray;
void func(int count) {
int i;
myarray = (mystruct*)malloc(count*sizeof(mystruct));
for (i = 0; i < count; i++) {
myarray[i].xx = yy;
}
}
// Alternative 2, array of pointers to entries.
mystruct **myarray;
void func(int count) {
int i;
myarray = (mystruct**)malloc(count*sizeof(*mystruct));
for (i = 0; i < count; i++) {
myarray[i] = (mystruct*)malloc(sizeof(mystruct));
myarray[i]->xx = yy;
}
}
/Per W
On Thu, 24 Oct 2002, Scott Williams wrote:
> Hi,
>
> I'm working in C (no C++ please). Got a couple of questions related to
> dynamic allocation and in particular, dynamically allocating an array of
> structs.
>
> First, what is the duration of memory allocated by malloc (etc.)? In
> particular, I want to dynamically allocate/de-allocate several global
> variables within a single subroutine called from main and so want to be sure
> that the allocated memory exists beyond the scope of that subroutine.
>
> Second, it is my understanding that it is perfectly acceptable to have an
> array of structs. E.g.,
>
> struct mystruct {
> double var1;
> long var2;
> etc...
> }
>
> . . .
>
> struct mystruct data[100];
>
> Is this correct? If so, what then is the calling sequence to dynamically
> allocate an array of structs, and, in particularly, make the result
> available globally?
>
> Thanks for your help (& sorry if this is naive).
>
> Scott Williams
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
> http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Per W. <pw...@ia...> - 2002-10-24 13:07:19
|
EMA System email: pw...@ia... Per Westermark web: http://iapetus.neab.net Vargvaegen 174B phone: +46 8 410 17 198 S-906 42 Umeaa Sweden On Thu, 24 Oct 2002, Daniel Glenfield wrote: > Do you need to use BYTE? you seem to be typecasting a lot. > You've allocated memory with new > BYTE *CalledPartyNumberStruct =3D new BYTE[1024]; > then used malloc to allocate more memory later, why is that? >=20 >=20 >=20 >=20 > >From: Christian Wallukat <Chr...@vo...> > >To: Daniel Glenfield <sp...@ho...>,=20 > >dev...@li... > >Subject: AW: [Dev-C++] Strange phenomenon > >Date: Thu, 24 Oct 2002 14:18:29 +0200 > > --> Is there a reason to declare the input parameters as arrays of --> characters? If the input is a string of digits, the logical --> input parameters would be: --> (const char CalledPartyNumber[],const char CallingPartyNumber[]) --> or: --> (const char* CalledPartyNumber,const char CallingPartyNumber) > >unsigned Connect(char CalledPartyNumber[1024], char > >CallingPartyNumber[1024]) > >{ > > _cmsg=09=09=09=09=09 CMSG; > > int=09=09=09=09=09 error; > > long=09=09=09=09=09 Controller; > > unsigned short=09=09=09 CIPValue; > > > > > > > > Controller =3D GetFreeController(); > > if (Controller =3D=3D -1) > >=09{ > >=09=09/*----- if no available controller use the first one for > >correct -----*/ > >=09=09/*----- error signaling -----*/ > >=09=09Controller =3D 1; > >=09}; > > > > int Connection =3D GetFreeLine(); > > > >=09if (Connection =3D=3D -1) > >=09{ > >=09=09printf("Error: no available connection identifiers\n"); > >=09=09/*----- no OS resources -----*/ > >=09=09return 0x1108; > > }; > > > > > > > >=09/*----- use ConnectionIdentifier as Messagenumber -----*/ > > CONNECT_REQ_HEADER(&CMSG, (WORD)dwApplID, (unsigned short)Connectio= n, > >Controller); > > > > /*----- build up service mask -----*/ > > > > CONNECT_REQ_CIPVALUE(&CMSG) =3D 0x1; > > > > CONNECT_REQ_CALLEDPARTYNUMBER(&CMSG) =3D SetNumber=20 > >(CalledPartyNumber);; > > CONNECT_REQ_CALLINGPARTYNUMBER(&CMSG) =3D SetNumber=20 > >(CallingPartyNumber); > > CONNECT_REQ_B1PROTOCOL(&CMSG) =3D B1PROTOCOL; > > CONNECT_REQ_B2PROTOCOL(&CMSG) =3D B2PROTOCOL; > > CONNECT_REQ_B3PROTOCOL(&CMSG) =3D B3PROTOCOL; > > CONNECT_REQ_B3CONFIGURATION(&CMSG) =3D B3CONFIGURATION; --> CMSG was declared inside this function. Does it have a destructor, --> or where will the numbers allocated by SetNumber calls be released? > > > > --> Where was error supposed to get initialized? > > return error; > >}; > > > > > > > > > > > > > > > > > >BYTE *SetNumber(char Number[1024]) > >{ --> Why allocation of 1024 bytes. The concept of storing the length of --> Number in the first byte, can not span such large an array. > >=09BYTE *CalledPartyNumberStruct =3D new BYTE[1024]; > > > > if (strlen(Number) >=3D 1) > >=09{ --> Here youu will leak the 1024 bytes allocated above > >=09=09int len; > > > >=09=09len =3D strlen(Number); > > > >=09=09/*----- \xLen\x80 STRING '\0' -----*/ > > > >=09=09CalledPartyNumberStruct =3D (unsigned char *)malloc(len + 2 + > >1); > > --> What happens if len > 254? Your single byte for length of overflow. > >=09=09CalledPartyNumberStruct[0] =3D (unsigned char)(len + 1); > >=09=09CalledPartyNumberStruct[1] =3D 0x80; > > > >=09=09strcpy ((char *)&(CalledPartyNumberStruct[2]), Number); ---> Missing else block, to initialize the allocated array. > > }; > > > >=09return CalledPartyNumberStruct; > >}; > > > >-----Urspr=FCngliche Nachricht----- > >Von: Daniel Glenfield [mailto:sp...@ho...] > >Gesendet am: Donnerstag, 24. Oktober 2002 14:14 > >An: Chr...@vo...; dev...@li... > >Betreff: Re: [Dev-C++] Strange phenomenon > > > >Could be a scope problem. You'll need to show us the functions. > > > > > > >From: Christian Wallukat <Chr...@vo...> > > >To: "Dev-Cpp-Users@Lists. Sourceforge. Net (E-Mail)" > > ><dev...@li...> > > >Subject: [Dev-C++] Strange phenomenon > > >Date: Thu, 24 Oct 2002 13:51:23 +0200 > > > > > >Hi List, > > > > > > > > >i have a strange phenomenon in my project: > > > > > >I call a function: Test(char szTest[1024]) with Test("test"); > > > > > >In that function another Function (like the first) will be called: > > >Test2(szTest); > > > > > >the adress of szZest is 0x000000000.... > > > > > >and the content is empty .... > > > > > > > > >Anyone an Idea ???? > > > > > >Kind r > > > > > >Chris > > > > > > > > >------------------------------------------------------- > > >This sf.net email is sponsored by: Influence the future > > >of Java(TM) technology. Join the Java Community > > >Process(SM) (JCP(SM)) program now. > > >http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/jav= avote > > >_______________________________________________ > > >Dev-cpp-users mailing list > > >Dev...@li... > > >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > > >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > >_________________________________________________________________ > >Get a speedy connection with MSN Broadband. Join now! > >http://resourcecenter.msn.com/access/plans/freeactivation.asp >=20 >=20 > _________________________________________________________________ > Internet access plans that fit your lifestyle -- join MSN.=20 > http://resourcecenter.msn.com/access/plans/default.asp >=20 >=20 >=20 > ------------------------------------------------------- > This sf.net email is sponsored by: Influence the future=20 > of Java(TM) technology. Join the Java Community=20 > Process(SM) (JCP(SM)) program now.=20 > http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavo= te > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >=20 |