Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


afmack

Member Since 15 Jun 2012
Offline Last Active Oct 10 2012 02:50 AM

Posts I've Made

In Topic: Memory Allocation

01 July 2012 - 05:05 AM

Thanks Brother Bob! I shall read/practice with pointers some more. :D

In Topic: Memory Allocation

01 July 2012 - 04:34 AM

I'm stumped. It compiles fine, but when it gets to the for function in main that prints off the array it says I don't have access to it. Here's the revised code.

#include<iostream>

#include<cstdlib>

#include<ctime>

using namespace std;

void randomArrayFill( int *a, int size )

{

a = new int[size];

for( int i = 0; i < size; i++ )

{

  a[i] = rand() % 100;

}

}



int main()

{

//----Init--------------------------------------------------------------

int size = 0;

int *a = 0;

srand(0);

//----End Init----------------------------------------------------------



cout << "Enter the size of an array to create: ";

cin >> size;



randomArrayFill( a, size );



for( int i = 0; i < size; i++ )

{

  cout << a[i] << " ";

}

cin.get();

cin.get();

return 0;

}


In Topic: Memory Allocation

01 July 2012 - 04:12 AM

Thanks! I've got another issue, but I'm going to see if I can work it out before askin' another question. Thanks again! 0/

In Topic: -Help with some code-

23 June 2012 - 08:53 AM

Thanks Rad. I knew I should just sleep and take a look at it again, lol. :P And noted on the srand. I'll be sure to change that.

In Topic: -Help with some code-

23 June 2012 - 03:21 AM

Code snippet wasn't cooperating. >.<

PARTNERS