Thread: [Dev-C++] Database program (how do i do that?)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Flavio de S. <fla...@ne...> - 2002-02-10 13:09:48
|
Hey Listers: I am trying to learn cpp and I am trying to do a simple application with = a database ( just to hold some notes, comments, etc ). I have seen around some .dat files, and they seem to be a txt file. I kn= ow that cpp can create binary file as well.=20 Actually, I do not know how to start, then I got a few questions: 1) Which one is better txt or binary? (In my application all the data is = just text ) 2) How do I create a database with txt files or binary files? Any sugges= tions or a good tutorial in the web? 3) Once it was created, how do I perform a search in database? Do I need= an index table? (I don't even know how to do this) I got other questions, but I think I'll start with the basic ones. I'd appreciate some help with this. I have been studying cpp and I have p= assed through all those boring tutorials about language basics. Now I wan= t to do a real=20 application, simple, but real ! Thanks in advance.... Flavio de Souza fla...@ne... ICQ:78458203 Sert=E3ozinho - SP - Brasil |
|
From: Devin C. <dcc...@ya...> - 2002-02-10 17:19:26
|
> Hey Listers: > > I am trying to learn cpp and I am trying to do a simple application with a database ( just to hold some notes, comments, etc ). I'm learning C++ too, but have the advantage of a good-but-rusty knowledge of C. There are some decentish resources on the Web for this; most importantly, http://www.mindview.com/Books has two free books on C++. I've just started vol. 1 and it goes into more depth than the many online tutorials. > I have seen around some .dat files, and they seem to be a txt file. I know that cpp can create binary file as well. '.dat' just means 'data.' It could be in either format, theoretically. > Actually, I do not know how to start, then I got a few questions: > > 1) Which one is better txt or binary? (In my application all the data is just text ) Binaries are usually smaller, since the file doesn't have to hold all the messy spaces and such. However, text files have the advantage that they can be loaded into a text editor like NotePad and examined. This is helpful while debugging, or if you want the data file to be human-readable (e.g., a payroll listing.) If you -don't- want the data to be easily human-readable (say, for a game that keeps the data for the villains in a file), then binary is the way to go. > 2) How do I create a database with txt files or binary files? Any suggestions or a good tutorial in the web? I haven't played with file I/O streams yet. There are good tutorials on the web but it takes some time to find them. The complete Coronado tutorial at http://www.swcp.com/~dodrill/controlled/cppdoc/cpptutor.html is my favourite tutorial; I don't like the format it's stored in, but it's fairly thorough. Go through the text and examples carefully. The Coronado tutorial's main strength is that it anticipates questions very well - more than once, I was scratching my head about some detail or another in an example and the tutorial text said something like 'You may be wondering about...' or 'Observant students will notice...' Your mileage will, of course, vary. Another good tutorial is http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html. I don't like it as much as the Coronado tutorial, because it isn't as thorough - there's a lot that's skimped over. But it does talk about what object-oriented and modular programming are, and explains inheritance, is-a, has-a, and is-a-kind-of relationships very well. It's more geared towards theory than practice. > 3) Once it was created, how do I perform a search in database? Do I need an index table? (I don't even know how to do this) That isn't a C++ question; that's a computer science question. There are entire courses on this subject. (I've taken only half of one, but then again, I read my old computer science texts for fun every now and then.) For a first project I'd recommend just making the simplest stupidest linear searching algorithm possible, something like function data search( string SearchTarget) { while (!END_OF_DATA_FILE) { fileread name, data; if name = SearchTarget return data; } return SEARCH_FAILED; } If you write your search function 'modularly', then you can replace it later with something more sophisticated without changing any other part of the program. That's one of the main benefits of object-oriented programming. If you keep things simple, you'll have a working (if inefficient) prototype that you can change later. > I got other questions, but I think I'll start with the basic ones. > > I'd appreciate some help with this. I have been studying cpp and I have passed through all those boring tutorials about language basics. Now I want to do a real > application, simple, but real ! That's the stage I'm at. I was playing a game a few weeks ago and thought, 'You know, this game is so algorithmic and object-oriented it'd make a wonderful first C++ project.' Right now, I'm a module and a half from completing my prototype. > > Thanks in advance.... People have helped me, so I feel I ought to return the favour. :) All I can give, though, is advice from One Newbie To Another. --Devin Carless _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |
|
From: Ioannis V. <no...@ya...> - 2002-02-10 17:25:05
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Flavio de Souza > Sent: Sunday, February 10, 2002 4:08 PM > To: Dev-cpp > Subject: [Dev-C++] Database program (how do i do that?) > > > Hey Listers: > > I am trying to learn cpp and I am trying to do a simple > application with a database ( just to hold some notes, > comments, etc ). > > I have seen around some .dat files, and they seem to be a txt > file. I know that cpp can create binary file as well. > > Actually, I do not know how to start, then I got a few questions: > > 1) Which one is better txt or binary? (In my application all > the data is just text ) If you want portability, only text is portable.That is it can be read in all platforms. The catch is that text occupies more space. > 2) How do I create a database with txt files or binary files? In C or C++? > Any suggestions or a good tutorial in the web? > 3) Once it was created, how do I perform a search in > database? Do I need an index table? (I don't even know how to do this) You will think a way. It depends on various factors, what searches you will do, if you keep your records sorted ans by which criteria e.t.c.. > > I got other questions, but I think I'll start with the basic ones. > > I'd appreciate some help with this. I have been studying cpp > and I have passed through all those boring tutorials about > language basics. Now I want to do a real > application, simple, but real ! I also suggest "The C++ Programming Language" 3rd Edition or Special Edition by Bjarne Stroustrup the creator of C++. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.d2g.com * Alternative URL: http://run.to/noicys |
|
From: Benjamin L. <bl...@ta...> - 2002-02-13 00:29:49
|
Actually, text is, if anything, less portable than binary. Even between Windows NT and 98 there is a difference in text: NT uses unicode, while 98 uses an 8-bit character. Binary, however, is just a collection of bits in no particular format at all, so it can be ported to any machine at all, and read, as long as the program reading it knows how it is formatted. -BL On 10 Feb 2002 at 19:24, Ioannis Vranos wrote: > > -----Original Message----- > > From: dev...@li... > > [mailto:dev...@li...] On Behalf > > Of Flavio de Souza > > Sent: Sunday, February 10, 2002 4:08 PM > > To: Dev-cpp > > Subject: [Dev-C++] Database program (how do i do that?) > > > > > > Hey Listers: > > > > I am trying to learn cpp and I am trying to do a simple > > application with a database ( just to hold some notes, > > comments, etc ). > > > > I have seen around some .dat files, and they seem to be a txt > > file. I know that cpp can create binary file as well. > > > > Actually, I do not know how to start, then I got a few questions: > > > > 1) Which one is better txt or binary? (In my application all > > the data is just text ) > > > If you want portability, only text is portable.That is it can be read in > all platforms. The catch is that text occupies more space. > > > > 2) How do I create a database with txt files or binary files? > > > In C or C++? > > > > Any suggestions or a good tutorial in the web? > > 3) Once it was created, how do I perform a search in > > database? Do I need an index table? (I don't even know how to do this) > > > You will think a way. It depends on various factors, what searches you > will do, if you keep your records sorted ans by which criteria e.t.c.. > > > > > > > > I got other questions, but I think I'll start with the basic ones. > > > > I'd appreciate some help with this. I have been studying cpp > > and I have passed through all those boring tutorials about > > language basics. Now I want to do a real > > application, simple, but real ! > > > I also suggest "The C++ Programming Language" 3rd Edition or Special > Edition by Bjarne Stroustrup the creator of C++. > > > > Ioannis > > * Ioannis Vranos > * Programming pages: http://www.noicys.d2g.com > * Alternative URL: http://run.to/noicys > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |