How can I get my program to read a larger array ??


Posted on 16th Feb 2014 07:03 pm by admin

Hi:

I have this program that reads from an array to do calculations. The array are just the numbers '1' and '0' in different orders. My problem is that I get the array to read up to 10 characters but for this program I need to be able to read up to 1000 characters. Is there something in my code that I need to change or what am I doing wrong. My program compiles but when it reads it it gets the following error:
Code: terminate called after throwing an instance of 'std::bad_alloc' what(): St9bad_alloc Abort (core dumped)
Did you know?Explore Trending and Topic pages for more stories like this.

Any ideas ?? Thanks for the help

Rookie

Here is the code

Code: #include #include // for log using namespace std; double complexity(const double* S, double T) { double c = 1.0; int l = 1; do { int kmax =1; for (int i=0;i= T-1) return (++c); } if (k >= kmax) kmax = k+1; } ++c; l += kmax; } while (l < T); return c; } int main(void) { double T = 12.0; // length of string double* S = new double[100110101110]; double sumc = complexity(S,T); cout << "sumc = " << sumc << endl; double cnorm; cnorm = sumc*log((double)T)/(log(2.0)*((double)T)); cout << "cnorm = " << cnorm << endl; delete[] S; return 0; }
No comments posted yet

Your Answer:

Login to answer
318 Like 27 Dislike
Previous forums Next forums
Other forums

How do I know when getBounds Method is ready to be called.
I have an application that changes out stylesheets client side. Once I change stylesheet the browse

switch not getting value
what am i doing wrong?
i want to populate the country list according to the category
i want to

Weekly Calendar
Hi, I am looking at creating a weekly calendar. The calendar will read from Monday - Sunday. Does an

Where am I going wrong
Been trying to work this out for hours

I have two tables called 'Genres' and 'Films'. Genre

storing results of a function - previous result overwritten with new result
I have created a function to validate input.

function validate_dimension($value,$name) {
<

PHP & Java
Hello,

can PHP code be used inside java code?

Code: <SCRIPT LANGUAGE="Java

problem with php server update from mid 2009
Hi,

I have this navigation menu on 2 websites which used to work just fine. After a recent up

Error with login script
I am getting an error with my login script:

Error:
Code: Warning: Cannot modify header inf

How to make URL loads only on login
On my page, when a user login he's redirects to user_home.php. I made it also to open the chat scree

Read from forum
Haven't written anything forever and I would like to get back.
What I'm trying to do is getting t

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash