Codecademy / docs

Codecademy Docs is a collection of information for all things code. 📕

Home Page:https://www.codecademy.com/resources/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Edit] C++ Arrays

Emanuele-Tirendi opened this issue · comments

Type of Edit (select all that apply)

Clarify unclear content and/or terms, Add new content (definitions, codeblocks, etc.)

Description (optional)

In the subsection "Array indices" of this entry it is described how to initialize an array, how to change initialized elements and how to access initialized elements. It is also pointed out that the size of the array cannot be changed during runtime.

What needs to be added is in my opinion

  • the recommendation to not access uninitialized elements. E.g. if we have int arr[5] = {0, 1, 2}, then the elements at index 3 and 4 are not initialized and one should not access them before they're initialized, because there can be anything stored inside.
  • making the programmer aware of that even if an array arr has length n, you can access and modify with arr[n+1] which leads to undefined behaviour and can e.g. overwrite other variables. This one is especially important since I think that beginners could have some trouble to manage the array length information in their programs which could lead them to use index out of bounds. Since there is not an index out of bounds exception, not knowing this fact could lead them to have hard times debugging their program.

Code of Conduct

  • By submitting this issue, I agree to follow Codecademy Doc's Code of Conduct.

For Maintainers

  • Labels added
  • Issue is assigned

I'd like to be assigned to this issue.

Hey, I happen to be familiar with the basics of C++, which may help tackle this issue. Would you like to assign this issue for me?

Hey, I happen to be familiar with the basics of C++, which may help tackle this issue. Would you like to assign this issue for me?

I'm sorry I've changed my mind. I'm already working on another issue. Happy coding.

I am interested in taking this issue on.

@Emanuele-Tirendi I will like to be assigned to this issue as part of my code academy portfolio on GitHub .

@Emanuele-Tirendi I am interested in being assigned this issue for my GitHub portfolio project.

@leopeq21 @JamesMasterton I guess I cannot assign it to you. As far as I know I am not allowed to assign issues. I just created this issue and was waiting myself to be assigned to it. Either I misunderstood something about the workflows in codecademy or the responsible people actually forgot to assign someone.

ok, that's fine

🌸 Thanks for closing this Issue!
Please head over to the Docs Forum if you have any questions about Docs, or reply to the thread on Possible Content Discussion to share ideas and collaborate with other contributors, maintainers, or super users to determine good future issues that will help expand Docs!