Skip to content

Instantly share code, notes, and snippets.

@melvyniandrag
Created March 1, 2018 20:07
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 melvyniandrag/3a912af762cb351c5c2beab8beda478b to your computer and use it in GitHub Desktop.
Save melvyniandrag/3a912af762cb351c5c2beab8beda478b to your computer and use it in GitHub Desktop.
arrays, pointers, references
#include <iostream>
#include <iomanip>
typedef char myArr[12];
void printInfo( myArr &arr, myArr arr2, myArr* arr3 )
{
std::cout << std::setw(10) << "arr: " << std::setw(20) << arr << std::setw(10) << " arr2: " << std::setw(20) << arr2 << std::setw(10) << " arr3: " << std::setw(20) << arr3 << std::endl;
std::cout << std::setw(10) << "&arr: " << std::setw(20) << &arr << std::setw(10) << " &arr2: " << std::setw(20) << &arr2 << std::setw(10) << " &arr3: " << std::setw(20) << &arr3 << std::endl;
std::cout << std::setw(10) << "arr[0]: " << std::setw(20) << arr[0] << std::setw(10) << " arr2[0]: " << std::setw(20) << arr2[0] << std::setw(10) << " arr3[0]: " << std::setw(20) << arr3[0] << std::endl;
std::cout << std::setw(10) << "&arr[0]: " << std::setw(20) << &arr[0] << std::setw(10) << " &arr2[0]: " << std::setw(20) << &arr2[0] << std::setw(10) << " &arr3[0]: " << std::setw(20) << &arr3[0] << std::endl;
}
int main()
{
myArr arr{'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '\0'};
printInfo( arr, arr, &arr );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment