Notes on Writing in C++
I am taking a class on programming in C++ this semester and we are coding in Visual Studio. There are a couple tricks to writing the code that I wanted to save here for myself for future reference.
Using Visual Studio 2017
Write a console application (not a desktop application)
Program properties >> C/C++ >> General >> SDL checks >> NO
Program properties >> C/C++ >> Precompiled Headers >> Precompiled Header >> NOT USING PRECOMPILED HEADERS
\n is end line
To compile in command line:
Use x86 Native Tools Command Prompt for VS 2017
NOTE: <dir> lists the contents of the current directory (equivalent to <ls> in Linux)
To compile a program: <cl / EHsc filename.cpp>
To run the program: <filename>
To convert to UTF-8, copy the text into a PsPad window and save with the correct encoding.
Don't forget to do Project >> Add existing item... to add Fssimplewindow.cpp to the program so it compiles correctly!
To get user input in the form of an integer [1]:
char buffer[256];
fgets(buffer, 256, stdin);
answer = atoi(buffer);
To create an array of characters of a certain length [2]:
char foo[20] ;
References to slides from class:
L02 s53: pointers and call by reference
L06 s49: line stipple
L09 s11: new graphics code structure required by new MacOSX
L09 s19: sound
L01 s27: setting up VS2015
L08 s15: mouse state
L08 s18: mouse click and case-switch construction
L05 s47: intro to OpenGL functions
L06 s25: interactive space invaders program
L05 s55: circles
L10 s45: classes
L12 s10: constructors and destructors
L12 s32: ParseString function
Sources:
[1] http://www.cplusplus.com/reference/cstdlib/atoi/
[2] http://www.cplusplus.com/doc/tutorial/ntcs/