473,473 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Data Structure and making the size change

I would like to know if anyone can help me with this. I would like to load
a file into a data structure but dont know how. Here is an example file.

;File Example
;Created 03/04/99
[Command]
name = "2QCF_y"
command = ~D, DF, F, D, DF, F, y

[Command]
name = "5b"
command = b, b, b, b, b
time = 30
etc....

My question is if someone can help me to load any file (I know how to
open it) but then input it into a data structure where each case is

command = ......

My problem is making the data structure increase or decrease depending on
the number of commands. Can anyone help me with this by pointing me in the
right direction A little code would be nice but an explanation is just as
good. Thanks

Jul 22 '05 #1
3 1275

"dsa89" <ds***@vfemail.net> wrote in message
news:ff******************************@localhost.ta lkaboutprogramming.com...
I would like to know if anyone can help me with this. I would like to load
a file into a data structure but dont know how. Here is an example file.

;File Example
;Created 03/04/99
[Command]
name = "2QCF_y"
command = ~D, DF, F, D, DF, F, y

[Command]
name = "5b"
command = b, b, b, b, b
time = 30
etc....

My question is if someone can help me to load any file (I know how to
open it) but then input it into a data structure where each case is

command = ......

My problem is making the data structure increase or decrease depending on
the number of commands. Can anyone help me with this by pointing me in the
right direction A little code would be nice but an explanation is just as
good. Thanks


C++ has lots of data structures built in. One of the simplest to use is
called a vector. Here's a little sample

#include <vector>
#include <string>

struct Command
{
std::string name;
std::string command;
int time;
};

// here's your vector of commands
std::vector<Command> command_vector;

// here's how to add a command to the command vector
Command a_command;
command_vector.push_back(a_command);

// here's how to loop though all the commands
for (int i = 0; i < command_vector.size(); ++i)
print_command(command_vector[i]);

etc. etc.

Any decent C++ book will talk about the vector class and a whole lot more.
Perhaps you need to invest in one?

john
Jul 22 '05 #2
Just in a little hurry and am coding in c++ for the first time. Yes, I will
invest in one.

So that code will work for what I am looking for, or would I need to
expand it? Add something or other?

Thanks.

Jul 22 '05 #3

"dsa89" <ds***@vfemail.net> wrote in message
news:5a******************************@localhost.ta lkaboutprogramming.com...
Just in a little hurry and am coding in c++ for the first time. Yes, I
will
invest in one.

So that code will work for what I am looking for, or would I need to
expand it? Add something or other?

Thanks.


You will need to expand it A LOT.

Are you an experienced programmer (even if not in C++). You seem to have
given yourself quite a difficult and tedious project for a first attempt at
C++.

Are you sure that C++ is the most suitable language. Nothing in C++ makes it
especially suitable for what you have described so far. I would choose to do
this in C++ but only because I'm very familiar with the language, if you are
more familiar with a different language it might be better to stick with
that.

If you have programmed other languages before then 'Accelerated C++' by
Koenig and Moo might be suitable, but no-one learns C++ in a hurry.

john
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dmb000006 | last post by:
Hello, I have a database style data structure, each record has several fields. I would like to create a nested data structure that would let me 'query' the data on the value of certain...
2
by: Vince | last post by:
I have a very specific problem to solve but I cannot find a data structure for it. I don't know if I am posting on the good newsgroup but I cannot find a software.design group. I would like to...
4
by: Dan | last post by:
I'm trying to creat a data structure, that can be either a integer, double, string, or linked list. So I created the following, but don't know if it is the data structure itself causing problems,...
5
by: Alfonso Morra | last post by:
Hi, I am writing a messaging library which will allow me to send a generic message structure with custom "payloads". In many cases, a message must store a non-linear data structure (i.e....
12
by: Divick | last post by:
Hi all, does any one know of any data structure in which I can search the key and value equally fast? Though I could use hashes, but I can only search in constant time on key but not on value. If...
1
by: tony.fountaine | last post by:
I am working on a project to read a Bosch Measurement Data File (MDF). The file contains a number of blocks that can be read from the file using a baisc structure. For example the ID BLOCK is as...
5
by: Lloyd Dupont | last post by:
I'm attempting to write a fairly complex data structure. One part of the complexity is that all 8 data operations it supports delegate some code to virtual method. This is by design because I...
5
by: pt | last post by:
Hi, i am wonderng what is faster according to accessing speed to read these data structure from the disk in c/c++ including alignment handling if we access it on little endian system 32 bits...
4
by: Alexander Adam | last post by:
Hello folks, I got a few question on some basic data structure stuff. Sorry if those questions might sound too easy or such but after googling a lot I didn't find a real answer to all those...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.