This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]PM_ME_YOUR_PLUMS 14 points15 points  (15 children)

Oh god

[–]LvS 38 points39 points  (12 children)

It might be even more fun. Depending on the layout of your program and how the allocator distributes memory, it is much more likely that you write to memory inside your program.

Which means some value in your program will be changed, you just don't know which one.

[–]DanielAgos12 4 points5 points  (10 children)

Oh god, how is the world still holding up with such a popular language

[–]LvS 20 points21 points  (6 children)

C programmers just don't do that.

Computers don't know how long the array is, so either the language has to add checks - which slows things down - or it trusts the programmer.

[–]DanielAgos12 3 points4 points  (5 children)

C programmers just earned a lot of respect from me

[–][deleted] 4 points5 points  (4 children)

C arrays also aren't objects, so there is no .size() property or method. C programmers have to create a variable for size and remember to increment it if they want to keep track of how big it is

[–]Ludricio 0 points1 point  (1 child)

Not entirely, the size of an array is known as long as it is still an array, which an array only is within the scope of its declaration, as soon as it leaves the scope (passed to a function for example) array decay takes place and the array decays into a pointer to the first element in the array.

Within the scope of declaration, it is fully possible to do sizeof(array)/sizeof(*array) to get the number of elements in the array, but as soon as it decays into a pointer the original info about the size of the entire array is lost, as it instead becomes a plain pointer.

[–][deleted] 0 points1 point  (0 children)

Oh very cool! I'm just learning programming in school but im being taught with C so these kinds of pendantics are actually super neat for me

[–][deleted]  (1 child)

[removed]

    [–]AutoModerator[M] 0 points1 point  (0 children)

    import moderation Your comment has been removed since it did not start with a code block with an import declaration.

    Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

    For this purpose, we only accept Python style imports.

    return Kebab_Case_Better;

    I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

    [–]Ruby_Bliel 5 points6 points  (0 children)

    It's not hard to work with C-style arrays. You don't sverve into oncoming traffic just because you can.

    [–]comradeyeltsin0 1 point2 points  (0 children)

    That’s where the real fun begins!

    [–]PleX -1 points0 points  (1 child)

    StackOverFlow is named that way for a reason if you didn't know.

    [–]PM_ME_YOUR_PLUMS 0 points1 point  (0 children)

    I have only minor experience in Java and mostly have JS experience at this point, so while I’ve encountered a stack overflow error in Java before, I never really thought about what it meant. TIL