Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

allocation of memory...!!!

Status
Not open for further replies.
Oct 29, 2004
6
AU
hi guys..
here iam trying to allocate memory for arr...i wrote following code...but i got and error
"initializing' : cannot convert from 'int *' to 'int []'
There are no conversions to array types, although there are conversions to references or pointers to arrays"


int arr[] = new int[10];


is there any thing wrong with my vc+ compiler,...or ????
 
It should be declared
int* arr = new int[10];

You can use arr with the same notation as you would an array, ie, arr[3] is totally valid syntax.
 
that original method you used is from C# .NET

Skute

"There are 10 types of people in this World, those that understand binary, and those that don't!"
 
> that original method you used is from C# .NET
Heh - the wheel has turned full circle :)
The [] notation for a pointer was in the very earliest C compilers.

--
 
And C# would be
int[] arr = new int[10];
instead of
int arr[] = new int[10];
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top