473,779 Members | 2,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

huge 2-D array

is anyone know how to implement a huge 2-D array?
such as ' unsigned char a[1500][1500]; '
I compile and run it in VC 6.0, but it show me an error....
thank you guys

Apr 16 '06 #1
8 2300
lu**********@gm ail.com wrote:
is anyone know how to implement a huge 2-D array?
such as ' unsigned char a[1500][1500]; '
I compile and run it in VC 6.0, but it show me an error....
thank you guys


No errors here (gcc). Maybe there is an error somewhere else?
Please post the code that has problems.
Apr 16 '06 #2
For example:

void main(void){
unsigned char a[1500][1500];
}

I can compile it without error, but when I run it, it show me an
error.......
Is that array too big?

Apr 16 '06 #3
In article <e1**********@v olcano1.grnet.g r>,
Giannis Papadopoulos <ip******@inf.u th.gr> wrote:
lu**********@g mail.com wrote:
is anyone know how to implement a huge 2-D array?
such as ' unsigned char a[1500][1500]; '
I compile and run it in VC 6.0, but it show me an error....
No errors here (gcc). Maybe there is an error somewhere else?
Please post the code that has problems.


The problem is probably just that it is a big array. C implementations cannot
necessarily support huge arrays; VC 6.0 has been noted a few times before
as restricting the array size.

I'm going to guess further that the OP is trying to declare that array
as an 'auto' variable (i.e., a local variable in a routine.) The array
occupies about 2 1/4 megabytes, which is larger than some implementations
allow for local variables. Declaring the variable to be 'static' might
clear up the problem for the OP, if the routine is not called recursively.
If not, then the OP will likely need to malloc() the space.

--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
Apr 16 '06 #4
lu**********@gm ail.com wrote:
is anyone know how to implement a huge 2-D array?
such as ' unsigned char a[1500][1500]; '
I compile and run it in VC 6.0, but it show me an error....
thank you guys

Consider malloc(). 2,250,000 bytes is rather much for an array
definition. See the C FAQ for more about this.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Apr 16 '06 #5
thank you~!
I declared the variable into 'static', and there is no error now.

Apr 16 '06 #6
<lu**********@g mail.com> wrote in message
news:11******** *************@v 46g2000cwv.goog legroups.com...
For example:

void main(void){
unsigned char a[1500][1500];
}

I can compile it without error, but when I run it, it show me an
error.......
Is that array too big?


You should include context in your replies or people cannot tell what you
are talking about. Furthermore, that should have been:

int main(void)
{
unsigned char a[1500][1500];
return 0;
}

You can try to malloc() the same amount of memory and see if that fails too.
You can try the following:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
unsigned char *p;
if ((p=malloc(1500 *1500))!=NULL)
{
printf("Success !\n");
free(p);
}
else
{
printf("Failure !\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

or something with the same effect as the above.
Apr 16 '06 #7
lu**********@gm ail.com wrote:
thank you~!
I declared the variable into 'static', and there is no error now.


Please read the information below.

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Apr 16 '06 #8
lu**********@gm ail.com wrote:
is anyone know how to implement a huge 2-D array?
such as ' unsigned char a[1500][1500]; '
I compile and run it in VC 6.0, but it show me an error....
thank you guys

Sometimes it helps to make it static char[1500][1500],
on a number of compilers your type will be on the stack,
while the static one will be in general memory space.
(I am sure someone will object/declare it of topic.)
Apr 17 '06 #9

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

Similar topics

5
1714
by: Winston | last post by:
Hello, There: I would like to create a huge two-dimentational array in C, like 5000X5000. However, I always got sementation faults when accessing more than 2000X2000. Is there any way to overcome this issue? Thanks in advance!
4
1833
by: RubenDV | last post by:
I am trying to make a cipher with a 256-bit key but i have no idea how the store this key without using arrays of ints or something like that. I just need a type that is big enough to hold the entire key, because i am going to use multiplication operations and such, which i can impossibly use on arrays or so i think. Is there a way to treat an array as a single, huge number without really being that? Any help is appreciated!
1
2702
by: Reynardine | last post by:
I am calling a C/C++ DLL from C# and I am marshalling the parameters to the API call by doing a type conversion for each parameter. For example, here is my C++ API method : short int XENO_API XcDatabaseCodes ( HWND hwnd, char FAR * pszDatabase, char FAR * HUGE * FAR * pszItemCategories
6
3177
by: ad | last post by:
I have a huge sting array, there are about 1000 element in it. How can I divide the huge array into small ones, and there are one 10 elements in a small one array?
9
1620
by: Sakharam Phapale | last post by:
Hi All, I want to read data from one file and write that into another file. Which is a way to do it quickly in terms of processing time? Data to be transfer is huge one. E.g. 2147483458 bytes. So I can't use array as temporary data type. Since looping takes too much time, Is there any way to directly use
6
2465
by: Michael Gray | last post by:
VS 2003 VB.net Win2000 SP4 The System.Array class seems to be limited to 32 bit addresses, meaning that one can only assign 2^32 elements. Is there any way that I can have an array that allows 2^64 elements? Or doesn't the CLR support this on a 32 bit opsys? I suspect that I am going to have to make such a beastie myself...
1
2152
by: vipinvarkey | last post by:
hello; i need to create a very long array in c of the foll specification: a however i get an error telling that the array's size is too large.the help file advices either to use malloc or huge can anyone help me how to use "huge"command? any other methods without using pointers is recommended. Thanking you; Vipin
2
2908
by: M R | last post by:
I need to build and display a huge data grid (roughly 5000x5000). (I know it is difficult to view, but i need to do it anyway) the immediate problem i am facing is that it takes a VERY long time to add 5000 columns. i created an array of DataGridViewTextBoxColumn and called DataGridView Columns.AddRange(array). This still takes a VERY long time. i haven't even attempted to add the 5000 rows or calculate the values of each cell (25M of...
3
2165
by: Ahmad Jalil Qarshi | last post by:
Hi, I have a text file having size about 2 GB. The text file format is like: Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values For example consider following chunk of actual data:
0
9632
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9925
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6723
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.