Difference between revisions of "Intermediate C++ Game Programming Tutorial 3"

From Chilipedia
Jump to: navigation, search
(Video Timestamp Index)
Line 12: Line 12:
  
 
== Video Timestamp Index ==
 
== Video Timestamp Index ==
[https://www.youtube.com/watch?v=&&&&&&&&&& Tutorial 3]
+
[https://youtu.be/xcq0H01CWS4 Tutorial 3]
  
 
== Notes ==
 
== Notes ==

Revision as of 21:46, 27 May 2017

In this tutorial we start from the barest bone starting point. Using only two simple functions: _putch() to output a character onto the console and _getch() to read a key from the keyboard, we build up a concept and theory of string storage, basic text input and output, and parsing operations. It might seem like reinventing the wheel, but you know what they say. The squeaky wheel gets() the cheese. Seriously though, this shit is gonna give us a solid foundation of low-level understanding on which we can later build up a fortress of high-level C++ awesomeness.

Topics Covered

  • Console I/O with <conio.h>
  • ASCII encoding
  • Single quotes char literal '#'
  • Null-terminated character arrays (c-strings)
  • Double quotes c-string literal "#"
  • Difference between string in local array vs. char* to string in read-only memory
  • String buffers and buffer overflow prevention
  • Parsing a string to convert to an integral value

Video Timestamp Index

Tutorial 3

Notes

This stuff that we're doing here with the strings, don't get the wrong idea. This is not the way forward. We're doing this stuff right now because it makes sense to learn about low-level string bullshit at this point and it gives us a chance to practice out newly-acquired pointer skills. However, using c-strings widely in your code is a terrible idea. They are inconvenient and extremely error-prone. Not sexy at all

One we get our practice in with basic pointer ops, strings, file I/O, and memory management, we will be ditching that caveman shit and upgrading to C++ sexy shits. That means we will be ditching c-strings for std::string sometime in the nearish future. But that doesn't mean you can skip this stuff. If you wanna be top tier programmer, you should have this background info. And sometimes (like when you're interfacing with libraries/APIs for example) you still need to use c-strings, even if only a little.

Homework

Prompt the user to input a positive integer, and then find that number in the Fibonacci sequence. For example, if the user enters the number 9, you should output the 9th Fibonacci number (34) to the console. There's only one catch: you're not allowed to use any library functions except for _putch(), _getch(), and _kbhit(). You can use the functions that we have already developed in this video.

See also