dev-cpp-users Mailing List for Dev-C++ (Page 384)
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: Derick v. N. <der...@go...> - 2003-05-12 14:43:33
|
Good Idea, but still uses ODBC... I think the messy text export/import might be the way to go for this = project due to the time limitations involved. ODBC is the best thing = since sliced bread, but it is hell to explain to the computer = illiterate. Also I don't know how to install it from within my program. -d- ----- Original Message -----=20 From: iad929=20 To: Derick van Niekerk ; DevCPP=20 Sent: Thursday, May 08, 2003 8:05 PM Subject: Re: [Dev-C++] Access databases If you can understand templates, and you want something portable, why = don't you try Database Template Library? Mohammed ----- Original Message -----=20 From: Derick van Niekerk=20 To: DevCPP=20 Sent: Friday, May 09, 2003 5:20 PM Subject: [Dev-C++] Access databases Anybody know of a quick 'n dirty way to manipulate an access database = using DevCpp? Maybe a lib or a wrapper or something? Thanks -d- |
|
From: iad929 <ia...@jo...> - 2003-05-12 14:09:55
|
If you can understand templates, and you want something portable, why = don't you try Database Template Library? Mohammed ----- Original Message -----=20 From: Derick van Niekerk=20 To: DevCPP=20 Sent: Friday, May 09, 2003 5:20 PM Subject: [Dev-C++] Access databases Anybody know of a quick 'n dirty way to manipulate an access database = using DevCpp? Maybe a lib or a wrapper or something? =20 Thanks -d- |
|
From: iad929 <ia...@jo...> - 2003-05-12 14:09:53
|
> And a school exam coming up? > It is not an assignment at all nor an assessment. I am no more student or working for any company. All these data structures come from a booklet from a publisher about the books it publishes. Mohammed |
|
From: Derick v. N. <der...@go...> - 2003-05-12 12:11:01
|
I took a look at your program... Turn on debugging information under linker settings and run debug. Put = breakpoints (by clicking on the line number in the gutter) in your = program to specify when you want to check the values. Instead of running = your program, click on debug. Add a watch for every variable you want to = check - and step through your code by clicking on 'next step'. It will = help if you resize the windows so both DevCpp and your pragram windows = are visible. It gets a bit tricky when you get to the scanf function, = but you'll get it. As for the bug in your program - you'll notice that you are dividing two = integers and storing the result in a float. To get a float value, you = will need to typecast, or declare suma as a float variable too. replace: media =3D (suma / ELEMENTOS); with: media =3D ((float)suma / ELEMENTOS); hope this helps. -d- ----- Original Message -----=20 From: jose gonz=E1lez=20 To: Dev...@li...=20 Sent: Monday, May 12, 2003 12:40 PM Subject: [Dev-C++] debugging Please , I need some basic tips to debugging a little program with = devcpp 4.9.8.0. Thank you |
|
From: <ja...@da...> - 2003-05-12 10:37:08
|
Please , I need some basic tips to debugging a little program with = devcpp 4.9.8.0. Thank you |
|
From: Vlada D. <dj...@im...> - 2003-05-12 07:03:37
|
This is the message that was posted on this list a whilw ago. Maybe it = can help. -------------------------------------------------------------------------= ------------ ----- Original MessHi Antonio, This is a response to your first question. Yes, Dev-C++ can be used to access many types of databases. Here's a general how-to approach, direct without using ODBC, that is, = using the client's API. 1. Download the database and any client libraries (both source and = binaries) from the database's website. For example, my latest R & D is on using SQLite, a cross-platform = embeddable SQL database. http://www.sqlite.org 2. See if there are any DLLs (pre-compiled binaries), the required = header file or files and any .def files. Look in the samples or test folder. Usually there are simple source = that tells you which header files are required. Also, look in the folder which contains the header files to locate the required header files. 3. From the provided DLL, you need to create a library file with .a extension. Use the dlltool.exe. This program comes with Dev-C++. For example: dlltool -Dsqlite.dll -dsqlite.def -llibsqlite.a 4. Once you have this .a file, the .h file and the .dll file, you're = ready to write client programs to "talk" with the database server. You then copy this .a file into your Dev-C++'s lib directory. Copy the .h file or files into the Dev-C++'s include directory. Copy the .dll into the Windows system directory. 5. Create a new Dev-C++ project. Try to find the simplest example code in the source distribution. Study the example makefile or project file. Get an idea of which = defines and/or compiler switches are required. Modify/add these defines to your project file. Remove the default template code and insert the sample code. Try to = compile. Notes: If the above .a file does not work or if there is no .def file, you'll = need to create a .def file: This is from the MinGW FAQ: <begin extract> However, for __stdcall functions, the above method does not work. For = MSVC will prefix an underscore to __stdcall functions while MinGW will not. = The right way is to produce the DEF file using the pexports tool from http://www.is.lg.ua/~paul/devel/binutils.html and filter off the first underscore by sed: pexports testdll.dll | sed "s/^_//" > testdll.def Then, when using dlltool to produce the import library, add `-U' to = the command line: dlltool -U -d testdll.def -l libtestdll.a <end extract> This approach I've described works for DLLs written in C, i.e. __cdecl functions. It works for MySQL's DLL and also SQLite's DLL. Instead of using the provided DLL, if you want to static link, you'll = need to compile the client library source. It can be simple or complicated depending on the source. You can also try to compile a DLL using the = client library source. For SQLite, the static lib is very simple to create. Use Dev-C++ to = create a new project for Static Library, select C Project, then insert the = SQLite C source codes. Compile and the .a file is generated. For MySQL, I've = not done it. Someday I'll try to allocate some time to do it and only if I feel = brave enough to try to debug compile time errors. :-) There used to be pre-compiled .a libs for MySQL from Johnny Dog = website but the last time I checked the site was down. I hope this helps. Regards, Yeoh ~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~ ICT eBooks by Yeoh HS Free Downloads at http://www.yeohhs.com ~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~ age -----=20 = -------------------------------------------------------------------------= ------------- From: Derick van Niekerk=20 To: DevCPP=20 Sent: Friday, May 09, 2003 4:20 PM Subject: [Dev-C++] Access databases Anybody know of a quick 'n dirty way to manipulate an access database = using DevCpp? Maybe a lib or a wrapper or something? =20 Thanks -d- |
|
From: Derick v. N. <der...@go...> - 2003-05-12 06:39:22
|
Thanks. I am sure I'd be able to find an odbc wrapper but I was thinking more along the lines of how M$VC++ is able to access an access database without needing to have the datasources set up under ODBC sources. I am writing a programto read information from scales (as in weighing) into a database. My brother is selling these scales and the company he works for will pay royalties for every scale the program is distributed with. I need to have the program easy to set up becaus their average customer barely knows where to switch on the pc let alone set up ODBC. I was thinking of doing the entire thing in access and I have the database already set up - I just need a small program to handle the task of getting information from the serial port (no problem) and writing it directly into the appropriate table of the access database. Importing and exporting is very messy and I'd rather not do it if I can work around it. Thanks again for all your help guys! -d- ----- Original Message ----- From: "Mark Livingstone" <mli...@ip...> To: <dev...@li...> Sent: Monday, May 12, 2003 5:17 AM Subject: Re: [Dev-C++] Access databases On Fri, 9 May 2003 16:20:39 +0200 "Derick van Niekerk" <der...@go...> wrote: > Anybody know of a quick 'n dirty way to manipulate an access database > using DevCpp? Maybe a lib or a wrapper or something? Well, DevCpp is only a development environment which supports C and C++ programming. If I were you, I'd Google for an ODBC class or wrapper. There are heaps of them out there. I know in times gone by I've seen them mentioned in various projects over at Sourceforge.net. HTH! |
|
From: Mark L. <mli...@ip...> - 2003-05-12 03:18:30
|
On Fri, 9 May 2003 16:20:39 +0200 "Derick van Niekerk" <der...@go...> wrote: > Anybody know of a quick 'n dirty way to manipulate an access database > using DevCpp? Maybe a lib or a wrapper or something? Well, DevCpp is only a development environment which supports C and C++ programming. If I were you, I'd Google for an ODBC class or wrapper. There are heaps of them out there. I know in times gone by I've seen them mentioned in various projects over at Sourceforge.net. HTH! |
|
From: Matthews <dem...@uw...> - 2003-05-12 02:23:55
|
If it's a char, then you can just use atoi([var]) or (int)[var]+1. I'm wondering what your database field is though. If it's like MySQL, then every field returned is a string value, in which case you'd use something like this: int val =3D atoi(returned_field)+1; You'd have to have your own updating code, as your description doesn't give much to go by. At 10:51 AM 11/05/2003 +0100, Daniel Glenfield wrote: >I'm interested to know why you would add 1 to a char, but you can convert= =20 >using atoi() > >it's something like > >int Buffer[10]; // create a buffer >atoi(Buffer, StringName, 10); // Where to store the int, your string to= =20 >convert, and the base type (10 for decimal). > >Do a search on google or msdn. > > >>From: "Fernando Correa da Concei;=E1o" <fer...@te...> >>To: dev...@li... >>Subject: [Dev-C++] Converting types(How to do it?) >>Date: Sat, 10 May 2003 17:08:29 -0300 >> >>Hi! >>I=B4m trying to use a database, but I need this, I have a field(a year by= =20 >>example), it=B4s a char. >>What I need is convert it to an int, add +1 and convert again to char. >> >>Thanks! >> >> >> >>------------------------------------------------------- >>Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara >>The only event dedicated to issues related to Linux enterprise solutions >>www.enterpriselinuxforum.com >> >>_______________________________________________ >>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 > >_________________________________________________________________ >Worried what your kids see online? Protect them better with MSN 8=20 >http://join.msn.com/?page=3Dfeatures/parental&pgmarket=3Den-gb&XAPID=3D186&= DI=3D1059 > > > >------------------------------------------------------- >Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara >The only event dedicated to issues related to Linux enterprise solutions >www.enterpriselinuxforum.com > >_______________________________________________ >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: jose i. c. <ji...@fr...> - 2003-05-12 00:12:03
|
Boy, these kids have real nice, nowdays! :-) I remember back in 82-86 (yes, I'm dating myself), the nights that I spent in the labs compiling cobol, fortran, pascal and assembler programs! There were no lists to get help from. :-) Just kidding Mohammed. Just adding a bit on Per's statement. ----- Original Message ----- From: "Per Westermark" <pw...@ia...> To: "iad929" <ia...@jo...> Cc: <dev...@li...> Sent: Sunday, May 11, 2003 5:41 PM Subject: Re: [Dev-C++] Data Structures > And a school exam coming up? > > /Per W > > On Thu, 8 May 2003, iad929 wrote: > > > Hi... > > > > I want someone of you help me to understand the following data structures > > and how to implement them in C++: > > 1. splay tree > > 2. skip list > > 3. Batcher's sorting networks > > > > I don't have at the moment the ability to visit web sites. I have only > > email. > > > > Mohammed > > > > > > > > ------------------------------------------------------- > > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > > The only event dedicated to issues related to Linux enterprise solutions > > www.enterpriselinuxforum.com > > > > _______________________________________________ > > 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 > > > > > > ------------------------------------------------------- > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > The only event dedicated to issues related to Linux enterprise solutions > www.enterpriselinuxforum.com > > _______________________________________________ > 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...> - 2003-05-11 21:42:55
|
And a school exam coming up? /Per W On Thu, 8 May 2003, iad929 wrote: > Hi... > > I want someone of you help me to understand the following data structures > and how to implement them in C++: > 1. splay tree > 2. skip list > 3. Batcher's sorting networks > > I don't have at the moment the ability to visit web sites. I have only > email. > > Mohammed > > > > ------------------------------------------------------- > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > The only event dedicated to issues related to Linux enterprise solutions > www.enterpriselinuxforum.com > > _______________________________________________ > 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: iad929 <ia...@jo...> - 2003-05-11 20:37:35
|
Hi... I want someone of you help me to understand the following data structures and how to implement them in C++: 1. splay tree 2. skip list 3. Batcher's sorting networks I don't have at the moment the ability to visit web sites. I have only email. Mohammed |
|
From: Daniel G. <sp...@ho...> - 2003-05-11 09:51:06
|
I'm interested to know why you would add 1 to a char, but you can convert using atoi() it's something like int Buffer[10]; // create a buffer atoi(Buffer, StringName, 10); // Where to store the int, your string to convert, and the base type (10 for decimal). Do a search on google or msdn. >From: "Fernando Correa da Concei;áo" <fer...@te...> >To: dev...@li... >Subject: [Dev-C++] Converting types(How to do it?) >Date: Sat, 10 May 2003 17:08:29 -0300 > >Hi! >I´m trying to use a database, but I need this, I have a field(a year by >example), it´s a char. >What I need is convert it to an int, add +1 and convert again to char. > >Thanks! > > > >------------------------------------------------------- >Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara >The only event dedicated to issues related to Linux enterprise solutions >www.enterpriselinuxforum.com > >_______________________________________________ >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 _________________________________________________________________ Worried what your kids see online? Protect them better with MSN 8 http://join.msn.com/?page=features/parental&pgmarket=en-gb&XAPID=186&DI=1059 |
|
From: <fer...@te...> - 2003-05-11 08:51:55
|
Hi! I´m trying to use a database, but I need this, I have a field(a year by example), it´s a char. What I need is convert it to an int, add +1 and convert again to char. It´s a c++ application. Thanks! PS: where can I find a guide about functions in header files like string.h iostream and others? |
|
From: <fer...@te...> - 2003-05-10 20:14:27
|
Hi! I´m trying to use a database, but I need this, I have a field(a year by example), it´s a char. What I need is convert it to an int, add +1 and convert again to char. Thanks! |
|
From: Emmanuel G. <Emm...@en...> - 2003-05-10 10:28:49
|
Hi, I'm a new user of Dev-C++. I have a question : is it possible to compile = for a 80186 processor ? Thanks, Emmanuel |
|
From: Daniel G. <sp...@ho...> - 2003-05-10 07:04:43
|
Hmm...I know you can use C+ with recordset objects to go through the records, but not sure about Access itself. Try looking at MSDN and do a search on google for "C++"+"Access" or maybe "Database" instead, as you could hook up the MySQL database to it. >From: "Derick van Niekerk" <der...@go...> >To: "DevCPP" <dev...@li...> >Subject: [Dev-C++] Access databases >Date: Fri, 9 May 2003 16:20:39 +0200 > >Anybody know of a quick 'n dirty way to manipulate an access database using >DevCpp? Maybe a lib or a wrapper or something? > >Thanks >-d- _________________________________________________________________ Hotmail messages direct to your mobile phone http://www.msn.co.uk/msnmobile |
|
From: Ioannis V. <iv...@at...> - 2003-05-09 14:36:19
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Samuel Keding > Sent: Thursday, May 08, 2003 11:42 PM > To: dev...@li... > Subject: [Dev-C++] Re: Longhorn > > > So what does all this mean to open source? If they are making > a new windows sdk that has special license restrictions, will > that phase minGW and other's ability to make compilers that > can compile code for the next OS generation? I do not know about license stuff, but what I do know is that the main .NET engine (CLI) which is the virtual machine mechanism, together with its assemby language are standardised by ECMA. This had as a result the open source Mono: http://www.go-mono.org/ Microsoft had the intention recently to apply for patents for its library. If the library is not available in the terms that Win32 is, one can create his own library. But I wouldn't understand why the .NET SDK would not be available in the terms that Win32 API is. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Ioannis V. <iv...@at...> - 2003-05-09 14:34:41
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf Of = =B3??S?? > Sent: Friday, May 09, 2003 10:49 AM > To: dev...@li... > Subject: [Dev-C++] Where can I download free this book TC++PLSE? >=20 >=20 > I have got TC++PL3rd, but I'd rather read the lastest > edition.Where's it free to download? The 3rd Edition is the latest edition (together with the Special = Edition). Ioannis Vranos =20 * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Ioannis V. <iv...@at...> - 2003-05-09 14:25:15
|
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of David =
McKen
Sent: Friday, May 09, 2003 5:52 AM
To: dev...@li...
Subject: [Dev-C++] Structures and Arrays and Pointers, Oh My!
Ok, I am having trouble using the above 3 together.
=20
Slay_msg is a array of pointers to characters (strings)
struct pc_data {
char * slay_msg[3];
}
=20
//a pointer to pc_data is a member of the char_data struct.
struct char_data {
...
pc_data * pcdata;
}
=20
//A pointer is declared of type char_data and initalized to the required
values.
char_data * ch =3D new char_data; //Assume everything has been =
initalized.
=20
Since you use operator new, it is a C++ program. In C you have to use =
the
malloc() family.
=20
=20
My question is: How do I access the strings in the array slay_msg?
=20
ch->pcdata->slay_msg[<index here>];=20
=20
C90:
=20
unsigned long i;
=20
char_data *ch=3Dmalloc(sizeof(*ch));
=20
if(!ch)
{
/* Error handling code */
}
=20
=20
ch->pcdata=3Dmalloc(sizeof(*(ch->pcdata));
=20
if(!(ch->pcdata))
{
/* Error handling code */
}
=20
=20
for(i=3D0; i<3; ++i)
{
ch->pcdata->slay_msg[i]=3Dmalloc(WHATEVER_SIZE_OF_CHARACTERS);
=20
if(ch->pcdata->slay_msg[i]=3D=3DNULL)
{
/* Error handling code */
}
}
=20
=20
=20
This low level stuff in C++98:
=20
#include <new>
=20
=20
// This try block in reality is usually applied in the function call, =
not in
the definition
// but i place it here to demonstrate the whole error handling =
mechanism.
=20
try
{
=20
char_data *ch=3Dnew char_data;
=20
ch->pcdata=3Dnew pc_data;
=20
=20
for(unsigned long i=3D0; i<3; ++i)
ch->pcdata->slay_msg[i]=3Dnew char[WHATEVER_SIZE_OF_CHARACTERS];
}
=20
catch(std::bad_alloc)
{
// Error handling code
}
=20
=20
=20
Ioannis Vranos
* Programming pages: <http://www.noicys.freeurl.com/>
http://www.noicys.freeurl.com
* Alternative URL 1: <http://run.to/noicys> http://run.to/noicys
* Alternative URL 2: <http://www.noicys.cjb.net/> =
http://www.noicys.cjb.net
|
|
From: Derick v. N. <der...@go...> - 2003-05-09 14:21:11
|
Anybody know of a quick 'n dirty way to manipulate an access database = using DevCpp? Maybe a lib or a wrapper or something? Thanks -d- |
|
From: David M. <ci...@ya...> - 2003-05-09 12:13:04
|
--- OROSZI_Balázs <or...@vp...> wrote:
> David McKen wrote:
> > Ok, I am having trouble using the above 3 together.
> >
> > Slay_msg is a array of pointers to characters (strings)
> > struct pc_data {
> > char * slay_msg[3];
> > }
> >
> > //a pointer to pc_data is a member of the char_data
> struct.
> > struct char_data {
> > ...
> > pc_data * pcdata;
> > }
> >
> > //A pointer is declared of type char_data and
> initalized to the required
> > values.
> > char_data * ch = new char_data; //Assume everything has
> been initalized.
> >
> > My question is: How do I access the strings in the
> array slay_msg?
>
> First of all, this is NOT a pure C program, as you are
> using "new", and
My mistake malloc is used (I just used new for simplicity)
> that is only in C++.
> Do you EXPLICITLY create pcdata inside ch? As it will
> *not* be created.
> This is what I have done, and this works:
>
> int main()
> {
> char_data *ch = new char_data;
> ch->pcdata = new pc_data;
> ch->pcdata->slay_msg[1] = "Dead!";
> printf("%s\n",ch->pcdata->slay_msg[1]);
> delete ch;
> return 0;
> }
>
> Another note: slay_msg is an array of pointers, so you
> can only assign
> values to them, not copy into them!
>
> Access is as follows: ch->pcdata->slay_msg[<index here>],
> what you used!
> Your problem is at creation I guess. You don't initialize
> pcdata I
> think. You must explicitly create it, as it's constructor
> won't get
> called (it is a pointer)!
I see, I will have to go to check that.
> But again, I WARN you! This is *not* pure C! C doesn't
> have "new", and
> structs should be typedefed, so you can create variables
> without writing
> the "struct" word before the declaration. ("struct
> char_data ch;" would
> be needed in pure C)
Those few code snippets are what poped into my head to
explain my problem.
> Try to compile it with gcc, not g++. It won't :)
>
> --
> Greetings,
> Balázs
Cool, This explains alot.
Thank you.
David Mcken
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
|
|
From: Frank W. <F.W...@wi...> - 2003-05-09 08:22:27
|
Hello, I use the Cygwin system and its libraries and I need the possibility to read out the CPU time with a higher resolution as defined in time.h. In the libc.hlp there is an example for a high resolution calendar. This high resolution calendar uses funktions described in /sys/time.h. But when I try this example nothing will happen. If I try to debug the code I get the following errormessage: Could not access memory at ..... I use WinNT4.0. Does someone can give me a hint its very important for me. Thanks in advance Frank |
|
From: <cy...@ya...> - 2003-05-09 07:49:26
|
I have got TC++PL3rd, but I'd rather read the lastest edition.Where's it free to download? _________________________________________________________ Do You Yahoo!? 相见不如聊天!不出门一样面对面!网络摄像头对对派送中~赶快用你的雅虎电邮帐号参与吧…… http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.messenger.yahoo.com/ |
|
From: <or...@vp...> - 2003-05-09 07:49:17
|
David McKen wrote:
> Ok, I am having trouble using the above 3 together.
>
> Slay_msg is a array of pointers to characters (strings)
> struct pc_data {
> char * slay_msg[3];
> }
>
> //a pointer to pc_data is a member of the char_data struct.
> struct char_data {
> ...
> pc_data * pcdata;
> }
>
> //A pointer is declared of type char_data and initalized to the required
> values.
> char_data * ch = new char_data; //Assume everything has been initalized.
>
> My question is: How do I access the strings in the array slay_msg?
First of all, this is NOT a pure C program, as you are using "new", and
that is only in C++.
Do you EXPLICITLY create pcdata inside ch? As it will *not* be created.
This is what I have done, and this works:
int main()
{
char_data *ch = new char_data;
ch->pcdata = new pc_data;
ch->pcdata->slay_msg[1] = "Dead!";
printf("%s\n",ch->pcdata->slay_msg[1]);
delete ch;
return 0;
}
Another note: slay_msg is an array of pointers, so you can only assign
values to them, not copy into them!
Access is as follows: ch->pcdata->slay_msg[<index here>], what you used!
Your problem is at creation I guess. You don't initialize pcdata I
think. You must explicitly create it, as it's constructor won't get
called (it is a pointer)!
But again, I WARN you! This is *not* pure C! C doesn't have "new", and
structs should be typedefed, so you can create variables without writing
the "struct" word before the declaration. ("struct char_data ch;" would
be needed in pure C)
Try to compile it with gcc, not g++. It won't :)
--
Greetings,
Balázs
|