Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Dynamic Arrays: Using malloc() and realloc()

dynamic array realloc malloc array

  • Please log in to reply
40 replies to this topic

#37 KonstantinosKouropalaths

KonstantinosKouropalaths

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 09 June 2014 - 06:25 AM

When i try that i get an error message at the pointer=malloc(2*sizeof(int));

which says invalid conversion from  void to int .. whats going wrong there?


  • 0

#38 gregwarner

gregwarner

    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1586 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 09 June 2014 - 08:34 AM

If pointer is a pointer of int type, then you need to cast it as such:
int *pointer = (int *) malloc(2*sizeof(int));

  • 0

ti-99-sig.png
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#39 KonstantinosKouropalaths

KonstantinosKouropalaths

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 09 June 2014 - 10:02 AM

oh ok it works now ! thanks a lot!


  • 0

#40 charlesdavis

charlesdavis

    CC Regular

  • Member
  • PipPipPip
  • 34 posts
  • Location:Noida
  • Programming Language:C, C++, C#, PHP, PL/SQL, Visual Basic .NET
  • Learning:Assembly, Fortran, Prolog

Posted 11 May 2015 - 10:06 PM

Good their are so many replies but all are in positve manner....As all are know malloc() and realloc() are used in dynamic resource locator..

 
  • 0

#41 nataliFar

nataliFar

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 07 January 2017 - 01:01 PM

Interlaced work fine in the test period when using Chrome. I'll try uploading something soon. Is there anything in the Phereo terms of service that is objectionable? Great work on the integration.
  • 0





Also tagged with one or more of these keywords: dynamic array, realloc, malloc, array