Skip to content

Instantly share code, notes, and snippets.

@BioBoost
Created October 26, 2022 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BioBoost/032125e52db894d385ace47f0863a720 to your computer and use it in GitHub Desktop.
Save BioBoost/032125e52db894d385ace47f0863a720 to your computer and use it in GitHub Desktop.
Using std::array as 2d buffer
#include <iostream>
#include <array>
#include <string>
using namespace std;
int main() {
cout << "Demo std::array" << endl;
std::array<std::array<std::string, 10>, 20> buffer;
buffer[0][0] = "hello";
buffer[0][2] = "world";
buffer[2][3] = "dude";
for (auto & line : buffer) {
for (auto & element : line) {
cout << element << " | ";
}
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment