[C / C++] A beginner's guide to C / C++ programming

Discussion in 'Mixed Languages' started by Michaela Joy, Mar 24, 2015.

  1. Michaela Joy

    Michaela Joy MDL Crazy Lady

    Jul 26, 2012
    4,071
    4,651
    150
    Hi All,
    If you're a beginner in C or C++, you might not want to (or be able to) make an investment in a professional development system. The good news is that you don't have to. There are a number of free products out there that can do the job nicely.

    If you just want to program in C, Pelles C is the way to go. Easy to use, does 32 and 64 bit code and comes with an IDE.

    You can find it here: http://www.smorgasbordet.com/pellesc/

    note: When you download the setup, you might get an error or a security warning; just save the file and run it anyway. It's safe. (But feel free to scan it before you run it anyway)

    For Linux people, the GNU tool chain is the de-facto standard of Linux development. There are a number of Windows ports, but my favorite so far is TDragons' TDM-GCC.

    You can find it here: http://tdm-gcc.tdragon.net/

    Grab the 64 bit installer, because it does both 32 and 64 bit executables.

    Unlike Pelles C, TDM-GCC does not come with an IDE. It's really up to you to find an IDE that you like.
    I use Code::blocks because it's already set up for TDM-GCC (Tdragon hangs out at the Code::blocks forum).

    You can find Code::blocks here: http://www.codeblocks.org/

    If you download Code::blocks, get it without a bundled compiler. Use the one at the link above. You can join the forum and ask questions about code::blocks, but no programming questions. They will ignore you or delete the post.

    Hopefully, this will get you started.

    Happy coding...

    :MJ
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. spacerogue

    spacerogue MDL Novice

    May 26, 2015
    5
    1
    0
    Microsoft Visual C++ Toolkit 2003
    //kael[dot]civfanatics[dot]net/files/VCToolkitSetup.exe

    The Microsoft Visual C++ Toolkit 2003 includes the core tools developers need to compile and link C++-based applications for Windows and the .NET Common Language Runtime:

    * Microsoft C/C++ Optimizing Compiler and Linker. These are the same compiler and linker that ship with Visual Studio .NET 2003 Professional!
    * C Runtime Library and the C++ Standard Library, including the Standard Template Library. These are the same static-link libraries included with Visual Studio.
    * Microsoft .NET Framework Common Language Runtime. Visual C++ can optionally build applications that target the Common Language Runtime (CLR).
    * Sample code. The toolkit includes four samples designed to showcase the powerful new features of the 2003 version, including new optimization capabilities, features to improve code-security and robustness, enhanced ISO C++ standards support, and the ability to use the .NET Framework library and target the CLR.

    Integrating Microsoft Visual Toolkit 2003 with Code::Blocks IDE
    //wiki[dot]codeblocks[dot]org/index[dot]php?title=Integrating_Microsoft_Visual_Toolkit_2003_with_Code::Blocks_IDE

    Microsoft Platform SDK August 2002 (DirectX 8.1 SDK Included)
    //download[dot]microsoft[dot]com/download/platformsdk/sdk/update/win98mexp/en-us/3672.1/FULL/PSDK-FULL.1.cab
    //download[dot]microsoft[dot]com/download/platformsdk/sdk/update/win98mexp/en-us/3672.1/FULL/PSDK-FULL.2.cab
    ...
    ...
    //download[dot]microsoft[dot]com/download/platformsdk/sdk/update/win98mexp/en-us/3672.1/FULL/PSDK-FULL.20.cab
    //download[dot]microsoft[dot]com/download/platformsdk/sdk/update/win98mexp/en-us/3672.1/FULL/PSDK-FULL.bat
    //download[dot]microsoft[dot]com/download/platformsdk/sdk/update/win98mexp/en-us/3672.1/FULL/extract.exe
    Minimum you will need the core of the PSDK if you want to compile for win32.

    WINDBG Debugging tools for Windows 6.4.7.2 (oldest version i can find)
    //msdl[dot]microsoft[dot]com/download/symbols/debuggers/dbg_x86_6.4.7.2.exe

    .NET Framework SDK Version 1.1
    //www[dot]microsoft[dot]com/en-us/download/details.aspx?id=16217

    Microsoft Visual C++ Toolkit 2003 (or VCToolkit, MVCT) is freely available and free for commercial use minimalistic compiler suite released by Microsoft. It consists of high quality C/C++ optimizing compiler (VC 7.1, which is much better than old VC++ 6.0) and linker, but obviously comes without IDE.

    Easy to follow C++ video tutorials:
    //www[dot]pvtuts[dot]com/cpp/cpp-introduction
    There are also other tutorials on the site so it is realy interesting to see the same topic in few different programming languages.
     
  3. Michaela Joy

    Michaela Joy MDL Crazy Lady

    Jul 26, 2012
    4,071
    4,651
    150
    @spacerogue: Here's that link you posted. It looks nice. :)

    http://www.pvtuts.com/cpp/cpp-introduction

    Personally, I stay away from Microsoft compilers. The main reason is the cost. You will find the Microsoft free compilers to be lacking, and at some point, you will be forced to buy the "Professional Edition" (About $500 USD) Unless you're willing to pay, you can't build apps for 64 bit targets. That means no 64 bit Windows Explorer extensions.

    I stay away from ATL as well. Any COM object can be created in C without the proprietary ATL junk.

    The SDK and the DDK is nice to have. But, to be honest, I simply google a function or windows message and the MSDN documentation comes up in my browser. Easy to search, and no bloatware on my development machine. :)

    :MJ
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. spacerogue

    spacerogue MDL Novice

    May 26, 2015
    5
    1
    0
    Organizing Code Files in C and C++, this is something that is rarely seen in books and sooner or later you'll want to get it right.

    //www[dot]gamedev[dot]net/page/resources/_/technical/general-programming/organizing-code-files-in-c-and-c-r3173
     
  5. Michaela Joy

    Michaela Joy MDL Crazy Lady

    Jul 26, 2012
    4,071
    4,651
    150
    For spacerogue :)

    http://www.gamedev.net/page/resourc...amming/organizing-code-files-in-c-and-c-r3173

    Source code organization is so important. But it's important to strike a balance. Avoid the temptation to break things up into a hundred files, but don't create a gargantuan file with everything in it.

    Also, coding style is -very- important. Write code as if you know that someone else is going to work on it. Don't over comment, but do comment when something isn't clear.
    And avoid the temptation to write obfuscated code...Someone else (more than likely your replacement) may very well be forced to rewrite it.

    Just some thoughts from an old Crazy Lady. :D

    :MJ
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Kondar

    Kondar Guest

    Okay, so this may be a silly question but please excuse me since I'm new to programming and have no one to ask.

    In which language are most Windows programs written, for example all the utilities of NirSoft or some of the programs found here on MDL, are they written in C/C++ ?

    I understand that some are written in C# and require the respective .net frameworks, but lets say I want to write a portable note-taking app for Windows (and I want it to work without any dependencies) , is C/C++ the only choice?

    To sum it up, I'm asking the following: I want to make a small GUI application for Windows, with buttons etc. which language should I choose? (consider the fact that I want to become a professional programmer and I'm ready to learn and work hard)

    Thanks
     
  7. Michaela Joy

    Michaela Joy MDL Crazy Lady

    Jul 26, 2012
    4,071
    4,651
    150
    #7 Michaela Joy, Sep 21, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)

    @Kondar: That's a good question. The short answer is Learn them all.

    Every language has its' purpose. For low-level coding (Device drivers, ring-0 code) x86 Assembler is the way to go. For application programming, You have many options. But the truth is, -every- high level compiled language distills down to Assembly language. So, at the very least, it won't hurt to familiarize yourself with assembler, the CPU and its' registers.

    Example: Most C / C++ compilers use this standard ASM preamble

    Code:
    Foo:
          PUSH SI    ; Borland compilers do this
          PUSH BP
          MOV BP,SP
          SUB SP, <However much space you need for local variables>
    
          . . . do your stuff here :)
          MOV SP, BP
          POP BP
          POP  SI
          RET
    
    In C
    Code:
        void Foo()
        {
         // A list of local variables
         . . . // Do your stuff here :)
        }
    
    When You understand this, You can make the machine do whatever you want it to do. :)

    Here's a link to info about Assembly Language.

    http://www.deinmeister.de/wasmfaq_e.htm

    And, of course, the definitive guides from Intel

    http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html

    And, C / C++

    http://en.cppreference.com/w/

    Of course You can come here and ask a question. There are many brilliant people here. (That's why I hang out here. :worthy:)

    Did I mention Object Pascal? :D

    :MJ
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. jeruka9-san

    jeruka9-san MDL Novice

    Oct 1, 2015
    2
    0
    0
    im only pascal and soon object pascal if someone want know those write to me :)
     
  9. BobSheep

    BobSheep MDL Guru

    Apr 19, 2010
    2,330
    1,377
    90
    I always write comments explaining "intent". Some code never requires comments that way and if my code doesn't do what was intended it's pretty obvious to someone else.
     
  10. Michaela Joy

    Michaela Joy MDL Crazy Lady

    Jul 26, 2012
    4,071
    4,651
    150

    Hi jeruka9-san, and Welcome to MDL. If you're studying Object Pascal, I suggest you take a look at the Lazarus project.

    http://www.lazarus-ide.org/

    Lazarus is a great IDE designed for the Delphi enthusiast. It's not exactly Delphi, but for a free product, it's quite amazing.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. jeruka9-san

    jeruka9-san MDL Novice

    Oct 1, 2015
    2
    0
    0
    yes i know that but thank you i like more freepascal as pirate i have delphi somewhere on my hdd but dont learn yet :)
     
  12. Tiger-1

    Tiger-1 MDL Guru

    Oct 18, 2014
    7,897
    10,733
    240
    ok thanks a lot for the app, I hope learn finally after several years with fear maybe then now is the time sure :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...