|"advice/tips for a beginner ordering (structuring) their first few programs."|
-- Don't use global variables until you understand how they can be used properly. Most teachers use global variables without informing their students about the risks associated with them.
-- Utilise function prototyping.
-- Use the standard library when possible.
-- Try to avoid "using namespace std
" and use "std::something
-- Avoid "char const *
" for strings and use "std::string
-- Avoid arrays and use "std::vector
" if possible.
-- Use comments to annotate your programs. For example, document each variable/object so you know why it's there, what it's used for, etcetera. Do this also for functions. After a while, this sort of documentation may not be necessary -- it depends on the project's complexity.
-- Use proper indentation when you code for easier reading.
-- Use "int main( )
" and avoid "void main( )
-- Always "return
" something from "main( )
-- Never call "main( )
-- Avoid "goto
" unless it's confined to a very small area
-- Always check for null-pointers before dereferencing them.
-- Use "const
" (or "constexpr
") instead of "#define
" for constant data.
I don't know what you know about C++ so some of the above may mean nothing to you.