Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • It's a very. A very-very bad approach to reallocate memory every single time when inserting a value. Commented Nov 17, 2013 at 21:31
  • it is also a very very bad idea to do this with an indeterminate pointer numbers, passed as the first parameter to realloc(). At the very least that thing should be initialized to NULL. And your scanf() should be checking for ==2, not just anything-but-EOF. Commented Nov 17, 2013 at 21:33
  • Arrays are not pointers. You are trying to treat a pointer-to-pointer as if it was an array of arrays, which it isn't. Search for a duplicate, there are already dozens of identical questions. Commented Nov 17, 2013 at 21:33
  • 1
    Furthermore, numbers[count] wouldn't be valid even if numbers was an array of count elements. Array indices start at zero. Commented Nov 17, 2013 at 21:34
  • I found this for simple array here stackoverflow.com/questions/2937409/resizing-an-array-with-c so i think why it wouldnt work for two dimensional Commented Nov 17, 2013 at 21:38