473,396 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dynamic array and table?

std::vector<intv creates a dynamic array where its possible to insert new
elements without doing any preallocation. But how about a dynamic double
array? I would like to have something like:
int M[a][b];

where a and b change be set during runtime and the size og M can vary, is
that possible?
Aug 11 '08 #1
3 1507
On Aug 11, 8:49*am, "saneman" <as...@asd.comwrote:
std::vector<intv creates a dynamic array where its possible to insert new
elements without doing any preallocation. But how about a dynamic double
array? I would like to have something like:

int M[a][b];

where a and b change be set during runtime and the size og M can vary, is
that possible?
Try:

std::vector< std::vector<int M;

Depending on your application, there may be better ways to do it. See
also this FAQ and following:

http://www.parashift.com/c++-faq-lit...html#faq-16.17

Cheers! --M
Aug 11 '08 #2
saneman wrote:
std::vector<intv creates a dynamic array where its possible to insert new
elements without doing any preallocation. But how about a dynamic double
array? I would like to have something like:
int M[a][b];

where a and b change be set during runtime and the size og M can vary, is
that possible?
It's not exactly equivalent, but you could try to get away with

std::vector<std::vector<int M(a, std::vector<int>(b));

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 11 '08 #3

"Victor Bazarov" <v.********@comAcast.netskrev i en meddelelse
news:g7**********@news.datemas.de...
saneman wrote:
>std::vector<intv creates a dynamic array where its possible to insert
new elements without doing any preallocation. But how about a dynamic
double array? I would like to have something like:
int M[a][b];

where a and b change be set during runtime and the size og M can vary, is
that possible?

It's not exactly equivalent, but you could try to get away with

std::vector<std::vector<int M(a, std::vector<int>(b));

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

Seems that boots:ublas has some dynamic vectors and matrices that I can use.
Aug 11 '08 #4

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

Similar topics

1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
7
by: murrayatuptowngallery | last post by:
After a few searches & inquiries here, I have a method of generating an html table populated with results of equations that works and wasn't too far up a learning curve for me, thanks to a helpful...
3
by: Brian Piotrowski | last post by:
Hi All, I've probably done this before, but for the life of me I can't remember how I did it. I need to move values from a DB table into an array to be used for other queries. The number of...
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
1
by: Skyer | last post by:
How to write? I have write program in C language. This program contain 1 array with struct. Every element of table must be dynamic list LIFO (stack). Adding and removing struct variable from...
0
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
2
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation...
1
by: superdad | last post by:
Hello; I have 2 questions: 1- I know you can allocate memory to an array dinamically in C and C++. But, can this be done if the array is part of a structure? 2- Can the size of a dynamic array...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.