Advertisement
Ginsutime

Array Cherno 4 - Strings

Feb 20th, 2022
996
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. int main()
  2. {
  3.     int size = 5;
  4.     //Array<int, 5> data; // Version of this class where T is set to int and size set to 5
  5.  
  6.     Array<std::string, 2> data;
  7.     data[0] = "Cherno";
  8.     data[1] = "C++";
  9.  
  10.     // memset(data.Data(), 0, data.Size() * sizeof(int)); // Set all integers inside of our array to 0 by setting all memory to 0.
  11.     // Not necessary, can do this the other way by taking first index of array and grab its index since the stack is contiguous in memory
  12.     //memset(&data[0], 0, data.Size() * sizeof(int));
  13.  
  14.     data[1] = 5;
  15.     data[4] = 8;
  16.  
  17.     for (size_t i = 0; i < data.Size(); i++) // Indexes throughout data
  18.     {
  19.         std::cout << data[i] << std::endl;
  20.     }
  21.  
  22.     std::cin.get();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement