IOT: C++ is pretty important, but getting your first VC++ app working is also important, here is how

For IOT, C++ and C are the thing to learn.  Javascript, yep.  HTM.  C# yep, for the same reason you learn Java.  Then learn some infrastructure or domain knowledge.

Ok, you open your community version of Visual Studio, and just want to use it as it exists.  You open the VC++ an then new project, then the console application, with no changes.  In my next blog, How to  compile a  “C” type of code.

What you did:

You enter the following in the ConsoleApplication.cpp file:

#include <iostream>   
using namespace std;
int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

It Didn’t Work!

Pretty basic, but it didn’t work.  If you took the default settings then your precomiled headers need to be in place.  Or you just set your compilation to not use precompiled headers.  Or you could do quite a few other things, but this is easy, on you project, right click and select Properties. 

Once you do that, add the directive: #include “stdafx.h” (see code below the property pages dialog):

image

Now the code works!

Code should look like the following:

#include <iostream>
#include "stdafx.h"    
using namespace std;
int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

image