Created
March 1, 2018 20:07
-
-
Save melvyniandrag/3a912af762cb351c5c2beab8beda478b to your computer and use it in GitHub Desktop.
arrays, pointers, references
This file contains 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
#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