(C) 2D array already populated with values after being initialised as empty

Problem description:

When initilaising an empty 2D jagged array in C, and outputting it’s contents without changing any of it’s values, a collection of hexadecimal values can be seen. These values seem to be dependent on other unrelated components of the code. For instance, adding a print statement prior to outputting the array’s contents will somehow change the contents of the array.

I decided to output it’s contents in the hex format out of curiosity and the values seemed significant enough for me to do some further testing.

Some relatively common values output are the hexadecimal numbers 0, 1, 100, 404, 6e0000, 528000 and ffffffff.

I can’t seem to work out any correlation between these values and the changes I make the the code.

Expected behavior:
Jagged array contains only 0s after being initialised.

Actual behavior:
Jagged array contains a variety of hexadecimal values after being initialised.

Steps to reproduce:
In C, declare a 2D jagged array with a known size and without defining any values. Then output the contents of the array.

Bug appears at this link:
2018 - Byway (C) (1) - Replit

Browser: Microsoft Edge
OS: Windows 11
Desktop app version (Avatar menu->“Version”) or NA: NA
Plan (Free, Hacker, Pro Plan): Free

I should also note that these errors do not occur when attempting to compile my code using a different online IDE. Hence why I’m reporting this issue on the replit forums.

Oh dear! Sounds like quite an annoying issue you’re having there pal! Sorry about that.


Thank you for your question. I’ve reached out to our engineering for help with this question and I will copy and paste their answers (as I don’t know a lot about C!):

The user isn’t initializing the array it seems. Take a look at the following links:

Hope this helps!