Lesson 2
Every thing in a computer is represented as bits (1s and 0s)
double is like float but for bigger numbers.
Integer division
Happens automatically based on types!
Explicit casting
int a = 20;
int b = 8;
a / b
// output: 2
static_cast<double>(a) / b
// output: 2.500000
Include #pragma once so that you don't redefine stuff
Macros
#define SEVEN 7
then use it like this:
std::cout << "message: " << SEVEN + num << std::endl;
void is a function that does not return anything
File I/O
#include <fstring>
ifstream infile(argv[1]);
if (!infile.is_open())
{
cerr << "unable to open file for reading:" << argv[1] << endl;
return 2;
}
ofstream outfile(argv[2]);
if (!outflie.is_open())
{
}
Use -Wall to turn on all warnings using g++
For example g++ -std==c++17 -Wall -o sums sum.cpp