Difference between revisions of "Intermediate C++ Game Programming Tutorial 4"
From Chilipedia
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | In this tutorial we tackle the | + | In this tutorial we tackle the topic of file IO using basic input output functions. We also learn about the basic concept of a stream, learn the difference between binary mode and text mode, and Chili even sneaks in a dank Cypress Hill reference. |
== Topics Covered == | == Topics Covered == | ||
− | * Opening a file with <code>std::ifstream</code> | + | * Opening a file for reading with <code>std::ifstream</code> |
* Reading with <code>get()</code> and monitoring the steam state with <code>good()</code> | * Reading with <code>get()</code> and monitoring the steam state with <code>good()</code> | ||
* Detecting the EOF (End of File) as well as errors in reading and file opening | * Detecting the EOF (End of File) as well as errors in reading and file opening | ||
Line 11: | Line 11: | ||
== Video Timestamp Index == | == Video Timestamp Index == | ||
− | [https:// | + | [https://www.youtube.com/watch?v=3LJYudvTaTs Tutorial 4] |
== Source Code == | == Source Code == | ||
Line 17: | Line 17: | ||
== Homework == | == Homework == | ||
− | Write a console application where the user can enter data pairs consisting of name:value in the form of c-string:unsigned int. Store | + | Write a console application where the user can enter a fixed number of data pairs consisting of name:value in the form of c-string:unsigned int. Store the entries in memory, and allow the user to print out a text chart of the entry data on demand. Also allow the user to save the entries to a file and load a file of entries into memory. You may not use any library functions beyond what is already being used in the Intermediate series. |
== See also == | == See also == | ||
* [[Intermediate C++ Game Programming Tutorial 5|Next in series (Tutorial 5)]] | * [[Intermediate C++ Game Programming Tutorial 5|Next in series (Tutorial 5)]] | ||
* [[Intermediate C++ Game Programming Series]] | * [[Intermediate C++ Game Programming Series]] |
Latest revision as of 10:36, 7 June 2017
In this tutorial we tackle the topic of file IO using basic input output functions. We also learn about the basic concept of a stream, learn the difference between binary mode and text mode, and Chili even sneaks in a dank Cypress Hill reference.
Topics Covered
- Opening a file for reading with
std::ifstream
- Reading with
get()
and monitoring the steam state withgood()
- Detecting the EOF (End of File) as well as errors in reading and file opening
- Writing to files with
std::ofstream
- The working directory of the application (where it looks for files)
- The difference between binary mode and text mode
- Writing and reading blocks of bytes with
write()
andread()
Video Timestamp Index
Source Code
Homework
Write a console application where the user can enter a fixed number of data pairs consisting of name:value in the form of c-string:unsigned int. Store the entries in memory, and allow the user to print out a text chart of the entry data on demand. Also allow the user to save the entries to a file and load a file of entries into memory. You may not use any library functions beyond what is already being used in the Intermediate series.