473,396 Members | 1,879 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.

How to make two-dimensional array put 'new' to use in C++?

Hi everyone.. I'm doing programing a maze problem.
I want to make a maze(array[5][7]) that use two-dimensional array...

but I don't know this...

{
int *a[7];
a[7] = new int [5];
}

this is result in segmentation error
help me... Thanks.

Jan 6 '07 #1
5 1612
ch******@gmail.com wrote:
Hi everyone.. I'm doing programing a maze problem.
I want to make a maze(array[5][7]) that use two-dimensional array...

but I don't know this...

{
int *a[7];
a[7] = new int [5];
}

this is result in segmentation error
See FAQ.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 6 '07 #2
ch******@gmail.com wrote:
{
int *a[7];
a[7] = new int [5];
}

this is result in segmentation error
When you create a[7] then elements are
in the range 0 to 6. "7" is past the end
of the array.

--
<\___/>
/ O O \
\_____/ FTB. For email, remove my socks.
We¡¯re judging how a candidate will handle a nuclear
crisis by how well his staff creates campaign ads.
It¡¯s a completely nonsensical process.
Jan 6 '07 #3
fungus wrote:
ch******@gmail.com wrote:
>{
int *a[7];
a[7] = new int [5];
}

this is result in segmentation error

When you create a[7] then elements are
in the range 0 to 6. "7" is past the end
of the array.
Definitely have to be careful with array ranges in C++, most compilers won't
give you an error if you try to go outside the index.
Jan 6 '07 #4

ch******@gmail.com wrote:
Hi everyone.. I'm doing programing a maze problem.
I want to make a maze(array[5][7]) that use two-dimensional array...

but I don't know this...

{
int *a[7];
a[7] = new int [5];
}

this is result in segmentation error
help me... Thanks.
there are 7 numbers from 0 to 6 and 7 isn't one of them.

Jan 6 '07 #5
On 5 Jan 2007 21:06:10 -0800 in comp.lang.c++, "ch******@gmail.com"
<ch******@gmail.comwrote,
>Hi everyone.. I'm doing programing a maze problem.
I want to make a maze(array[5][7]) that use two-dimensional array...
Avoid 'new' and bare naked arrays in application-level code.

std::vector< std::vector<int array(5, std::vector<int>(7));
Jan 6 '07 #6

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

Similar topics

3
by: Bert Boye | last post by:
I have two SQL query that I would like to make in to one, if possible Here is the first one: (Query4) SELECT rooms.DESCRIPTIO, rooms.ID, bookings1.DATE FROM bookings1 INNER JOIN rooms ON...
7
by: Kapt. Boogschutter | last post by:
I'm trying to create a function that has at least 1 Argument but can also contain any number of Arguments (except 0 because my function would have no meaning for 0 argument). The arguments...
11
by: Matt Kruse | last post by:
This is a common requirement - "freeze panes" in a table, so that some header rows and some columns on the left are frozen while the body content scrolls. This makes large tables more usable on...
10
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address,...
15
by: Hi5 | last post by:
Hi, I am designing a database for a client in which It has a client table including the followings: 1-Table Client 2-Table lookupcategory 3-Table Ctegory
0
by: Jongmin | last post by:
Hi! I am making HyperLinkColumn in datagrid. It is simple to make the hyerlinkcolumn with one datafield. <asp:HyperLinkColumn Text="NAME" DataNavigateUrlField="NAME"...
19
by: Swaregirl | last post by:
Hello, I would like to build a website using ASP.NET. I would like website visitors to be able to download code that I would like to make available to them and that would be residing on my...
2
by: tweety123 | last post by:
I want to write a generic function to compare two word documents and make changes in one so as to make it same as the another one. Also, I want to do the same with two text files.
8
by: Alexey Smirnov | last post by:
How to make bold part of the text in a Windows.Forms.Label? Thank you.
4
by: seberino | last post by:
I'm looking over the docs for the re module and can't find how to "NOT" an entire regex. For example..... How make regex that means "contains regex#1 but NOT regex#2" ? Chris
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.