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

Update Database
Hi All,


I have a problem with this:

Code: [Select]<?php
session_start();

Generate PDF
Hi guys,

I would like to know if there is a way to generate pdf when clicking on a link. In f

JQuery, Masterpage, and Control issue
Hey everyone, I am using JQuery in several sites so I thought it would be best to place the library

disabling a button server-side then re-enabling client-side breaks button postback
I have a tabbed container and a button (not in the container) on a page. If the first tab is selecte

Problem in OnClientClick and OnClick sync
Hi,Strange and irritating problem: I have below button declaration in markup of the aspx page:

Javascript using window.location seems to lose state
Not sure what forum so let me know if I'm in the wrong place. I have a main window with a ajax grid

Date Format
Hi there,

I have a date format like this right now:
Sat, 17 Oct 2009 17:04:00

I ne

Pagination
Hi All,

I think I'm finally getting somewhere with pagination!

I can now submit a quer

Is it possible to put an entire 500-page book in a database with PHP?
I am working on an intranet and I was wondering if its possible to code php with mysql to enter a fu

Sum of Values in an Array
This is probably really simple... but it's been years since I've written anything, so bare with me!<

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