Re: [Dev-C++] regarding memory allocation
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2006-10-13 13:48:38
|
When asking for help - always attach the code you have problems with.
Right now, we don't even know if you program in C or in C++, and if you
with "floating" means the data type "float" or just floating point
numbers.
The arrays are too large to allocate as auto, i.e. on the stack.
I'm sorry, but I don't know how to create nearly 5 arrays. The code below
will manage to create exactly 5 arrays:
// float allocation in C:
#include <stdlib.h>
#include <stdio.h>
enum {
ARRAY_SIZE = 50000,
};
int main() {
float* array1 = (float*)malloc(ARRAY_SIZE*sizeof(*array1));
float* array2 = (float*)malloc(ARRAY_SIZE*sizeof(*array1));
float* array3 = (float*)malloc(ARRAY_SIZE*sizeof(*array1));
float* array4 = (float*)malloc(ARRAY_SIZE*sizeof(*array1));
float* array5 = (float*)malloc(ARRAY_SIZE*sizeof(*array1));
printf("Everything allocated\n");
return 0;
}
// double allocation in C++:
#include <iostream>
int main() {
const int array_size = 50000;
double *array1 = new double[array_size];
double *array2 = new double[array_size];
double *array3 = new double[array_size];
double *array4 = new double[array_size];
double *array5 = new double[array_size];
std::cout << "Everything allocated" << std::endl;
}
/Per W
On Fri, 13 Oct 2006 gy...@cc... wrote:
>
> Hello All,
>
> Please help me with a trivial problemos.
>
> I want to create nearly 5 floating array of 60,000 each . When I run the
> program it gives error which I always do "Dont Send" to Microsoft. Please
> help me allocating these arrays without crashing the system as such even
> Dev C++. Please help me urgently...
>
> thanks
> with regards
> -gaurav
>
>
>
>
>
>
> Sayonara With Smile & With Warm Regards :-)
>
> G a u r a v Y a d a v
> Senior Executive Officer,
> Economic Research & Surveillance Department,
> Clearing Corporation Of India Limited.
>
> Address: 5th, 6th, 7th Floor, Trade Wing 'C', Kamala City, S.B. Marg,
> Mumbai - 400 013
> Telephone(Office): - +91 022 6663 9398 , Mobile(Personal) (0)9821286118
> Email(Office) :- gy...@cc... , Email(Personal) :-
> ema...@gm...
>
>
> ============================================================================================
> DISCLAIMER AND CONFIDENTIALITY CAUTION:
>
> This message and any attachments with it (the "message") are confidential and intended
> solely for the addressees. Unauthorized reading, copying, dissemination, distribution or
> disclosure either whole or partial, is prohibited. If you receive this message in error,
> please delete it and immediately notify the sender. Communicating through email is not
> secure and capable of interception, corruption and delays. Anyone communicating with The
> Clearing Corporation of India Limited (CCIL) by email accepts the risks involved and their
> consequences. The internet can not guarantee the integrity of this message. CCIL shall
> (will) not therefore be liable for the message if modified. The recipient should check this
> email and any attachments for the presence of viruses. CCIL accepts no liability for any
> damage caused by any virus transmitted by this email.
|