This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/cfbbe37b090687dd8a57acfbf7706844 | |
#include <iostream> | |
int main(int argc, char const *argv[]) { | |
int input_number{0}; | |
do { | |
std::cout << "Enter a number between 10 and 20: "; | |
std::cin >> input_number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/880c7bba03f62a3cf7e6a16321aacaf6 | |
#include <iostream> | |
int main(int argc, char const* argv[]) { | |
int number{42}; | |
int& number_reference = number; | |
int a_copy{number}; | |
int another_copy{-23}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/c92859aace3e06a76e11adee327d8224 | |
#include <cmath> | |
#include <cstdio> | |
#include <cstring> | |
#include <iostream> | |
// https://stackoverflow.com/questions/111928/is-there-a-printf-converter-to-print-in-binary-format | |
// Retrieved Feb. 2021 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/a3f48da332e04129d816ddf4bf64daf2 | |
#include <filesystem> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
int main(int argc, char const *argv[]) { | |
std::vector<std::string> args{argv, argv + argc}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/fba16c441b459231d6fc5d2e35d046aa | |
#include <filesystem> | |
#include <iostream> | |
int main(int argc, char const *argv[]) { | |
// works just like `pwd` | |
std::cout << std::filesystem::current_path().string() << "\n"; | |
return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/49124a3e4c73ad44ac331dc023b61326 | |
// Filename cpsc120_cat.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_cat.cc | |
// An implementation of the `cat` program which prints the contents of a file | |
// to the std::cout (stdout). | |
#include <fstream> | |
#include <iostream> | |
#include <string> | |
#include <vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/37b21d3ba3d4630be6d97dae1b8fbde1 | |
#include <array> | |
#include <iostream> | |
int main(int argc, char const* argv[]) { | |
std::array<int, 6> my_array{10, 11, 12, 13, 14, 15}; | |
for (const int& number : my_array) { | |
if (number % 2 != 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/ccd1c720a571b84e855c59e00f66df99 | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
int main(int argc, char const* argv[]) { | |
vector<std::string> arguments{argv, argv + argc}; | |
bool found{false}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/5b341c7d272ce7442754699351008d3e | |
// Filename cpsc120_fscat.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_fscat.cc | |
// An implementation of the `cat` program which prints the contents of a file | |
// to the std::cout (stdout) using the filesystem::path type. | |
#include <filesystem> | |
#include <fstream> | |
#include <iostream> | |
#include <string> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/77e6c030cb519c2cbb221a00eff2cbe2 | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
int main(int argc, char const* argv[]) { | |
std::vector<std::string> arguments{argv, argv + argc}; | |
bool should_skip_first{true}; |