| <<< C/C++ memory access demo v.2 | Index | Dereference operator >>> |
#include <iostream>
using namespace std;
int main()
{
//int MEMORY = 0; // BEFORE
char* location = "HELLO"; // NOW
for(;;) {
int offset;
cout << "character at offset: ";
cin >> offset;
// Show character at the specified location:
//cout << MEMORY[ (char*)location ] << "\n"; // BEFORE
//cout << MEMORY[ location ] << "\n"; // BEFORE
cout << location[ offset ] << "\n"; // NOW
break;
}
return 0;
}
| <<< C/C++ memory access demo v.2 | Index | Dereference operator >>> |