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)

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

PHP submit form script causing blank page
Im trying to submit a form using this script, however nothing shows up on the page, does anyone know

SQL query not working well
Hi,
I made a small table with 5 rows and want to make them an sql consult using rownum

Displaying image pathname instead of image
Hello

Im trying to upload and then display images from a mysql database - Its only basic and

retrieving more than one max key from an array?
so i have an array of 20 numerical values (0-100) that i need to order from highest to lowest and th

Need help: how to catch acess of undefined class properties
Hello. I am learning OO with PHP and have hit a problem.
Some code runs as perfectly valid code,

tell csv import script to ignore blank rows?
Hi i have the below script but i get an error if a row is blank ie a return in the csv file at the e

help with insert
Hi there,

I am trying to insert some data into a database, but for some reason, it is not ins

Batch Session SM35 stuck in status 'in Background
Hi Experts,

I am facing a problem with Batch Input session SM35.

The batch se

Variable uses and placement
I'm new to PL/SQL and am trying to learn about variable valid uses/placement (any pointers to any do

Help with setcookie()
Merry Xmas to those on this foruum
Older guy here with some experience but not allot so please be

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